Completed
Push — master ( 84cbf1...8002b4 )
by Jamie
02:29
created
classes/controllers/FrmSettingsController.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -2,26 +2,26 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmSettingsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		// Make sure admins can see the menu items
7 7
 		FrmAppHelper::force_capability( 'frm_change_settings' );
8 8
 
9
-        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
-    }
9
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
+	}
11 11
 
12
-    public static function license_box() {
12
+	public static function license_box() {
13 13
 		$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14
-        include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
-    }
14
+		include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
+	}
16 16
 
17
-    public static function display_form( $errors = array(), $message = '' ) {
18
-        global $frm_vars;
17
+	public static function display_form( $errors = array(), $message = '' ) {
18
+		global $frm_vars;
19 19
 
20
-        $frm_settings = FrmAppHelper::get_settings();
21
-        $frm_roles = FrmAppHelper::frm_capabilities();
20
+		$frm_settings = FrmAppHelper::get_settings();
21
+		$frm_roles = FrmAppHelper::frm_capabilities();
22 22
 
23
-        $uploads = wp_upload_dir();
24
-        $target_path = $uploads['basedir'] . '/formidable/css';
23
+		$uploads = wp_upload_dir();
24
+		$target_path = $uploads['basedir'] . '/formidable/css';
25 25
 
26 26
 		$sections = self::get_settings_tabs();
27 27
 
@@ -64,47 +64,47 @@  discard block
 block discarded – undo
64 64
 		wp_die();
65 65
 	}
66 66
 
67
-    public static function process_form( $stop_load = false ) {
68
-        global $frm_vars;
67
+	public static function process_form( $stop_load = false ) {
68
+		global $frm_vars;
69 69
 
70
-        $frm_settings = FrmAppHelper::get_settings();
70
+		$frm_settings = FrmAppHelper::get_settings();
71 71
 
72 72
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
73 73
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
74
-            wp_die( $frm_settings->admin_permission );
75
-        }
74
+			wp_die( $frm_settings->admin_permission );
75
+		}
76 76
 
77
-        $errors = array();
78
-        $message = '';
77
+		$errors = array();
78
+		$message = '';
79 79
 
80
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
81
-            $errors = $frm_settings->validate( $_POST, array() );
80
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
81
+			$errors = $frm_settings->validate( $_POST, array() );
82 82
 
83
-            $frm_settings->update( stripslashes_deep( $_POST ) );
83
+			$frm_settings->update( stripslashes_deep( $_POST ) );
84 84
 
85
-            if ( empty( $errors ) ) {
86
-                $frm_settings->store();
87
-                $message = __( 'Settings Saved', 'formidable' );
88
-            }
89
-        } else {
90
-            $message = __( 'Settings Saved', 'formidable' );
91
-        }
85
+			if ( empty( $errors ) ) {
86
+				$frm_settings->store();
87
+				$message = __( 'Settings Saved', 'formidable' );
88
+			}
89
+		} else {
90
+			$message = __( 'Settings Saved', 'formidable' );
91
+		}
92 92
 
93 93
 		if ( $stop_load == 'stop_load' ) {
94
-            $frm_vars['settings_routed'] = true;
95
-            return;
96
-        }
94
+			$frm_vars['settings_routed'] = true;
95
+			return;
96
+		}
97 97
 
98
-        self::display_form( $errors, $message );
99
-    }
98
+		self::display_form( $errors, $message );
99
+	}
100 100
 
101
-    public static function route( $stop_load = false ) {
102
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
101
+	public static function route( $stop_load = false ) {
102
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
103 103
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
104
-        if ( $action == 'process-form' ) {
104
+		if ( $action == 'process-form' ) {
105 105
 			self::process_form( $stop_load );
106
-        } else if ( $stop_load != 'stop_load' ) {
106
+		} else if ( $stop_load != 'stop_load' ) {
107 107
 			self::display_form();
108
-        }
109
-    }
108
+		}
109
+	}
110 110
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,16 +45,16 @@
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	public static function load_settings_tab() {
48
-		FrmAppHelper::permission_check('frm_change_settings');
48
+		FrmAppHelper::permission_check( 'frm_change_settings' );
49 49
 		check_ajax_referer( 'frm_ajax', 'nonce' );
50 50
 
51 51
 		$section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
52 52
 		$sections = self::get_settings_tabs();
53
-		if ( ! isset( $sections[ $section ] ) ) {
53
+		if ( ! isset( $sections[$section] ) ) {
54 54
 			wp_die();
55 55
 		}
56 56
 
57
-		$section = $sections[ $section ];
57
+		$section = $sections[$section];
58 58
 
59 59
 		if ( isset( $section['class'] ) ) {
60 60
 			call_user_func( array( $section['class'], $section['function'] ) );
Please login to merge, or discard this patch.
classes/views/frm-settings/form.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -191,10 +191,10 @@
 block discarded – undo
191 191
 					} else {
192 192
 						call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
193 193
 					}
194
-                } ?>
194
+				} ?>
195 195
             </div>
196 196
         <?php
197
-        } ?>
197
+		} ?>
198 198
 
199 199
         <p class="alignright frm_uninstall">
200 200
             <a href="javascript:void(0)" id="frm_uninstall_now"><?php _e( 'Uninstall Formidable', 'formidable' ) ?></a>
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
         </ul>
28 28
         </div>
29 29
 
30
-    <?php do_action('frm_before_settings'); ?>
30
+    <?php do_action( 'frm_before_settings' ); ?>
31 31
 
32 32
 	<form name="frm_settings_form" method="post" class="frm_settings_form" action="?page=formidable-settings<?php echo ( $a ? '&amp;t=' . $a : '' ); ?>">
33 33
         <input type="hidden" name="frm_action" value="process-form" />
34 34
         <input type="hidden" name="action" value="process-form" />
35
-        <?php wp_nonce_field('process_form_nonce', 'process_form'); ?>
35
+        <?php wp_nonce_field( 'process_form_nonce', 'process_form' ); ?>
36 36
 
37
-        <div class="general_settings tabs-panel <?php echo ($a == 'general_settings') ? 'frm_block' : 'frm_hidden'; ?>">
37
+        <div class="general_settings tabs-panel <?php echo ( $a == 'general_settings' ) ? 'frm_block' : 'frm_hidden'; ?>">
38 38
             <p class="submit">
39 39
 				<input class="button-primary" type="submit" value="<?php esc_attr_e( 'Update Options', 'formidable' ) ?>" />
40 40
             </p>
@@ -43,20 +43,20 @@  discard block
 block discarded – undo
43 43
 
44 44
             <p><label class="frm_left_label"><?php _e( 'Load form styling', 'formidable' ) ?></label>
45 45
                 <select id="frm_load_style" name="frm_load_style">
46
-                <option value="all" <?php selected($frm_settings->load_style, 'all') ?>><?php _e( 'on every page of your site', 'formidable' ) ?></option>
47
-                <option value="dynamic" <?php selected($frm_settings->load_style, 'dynamic') ?>><?php _e( 'only on applicable pages', 'formidable' ) ?></option>
48
-                <option value="none" <?php selected($frm_settings->load_style, 'none') ?>><?php _e( 'Don\'t use form styling on any page', 'formidable' ) ?></option>
46
+                <option value="all" <?php selected( $frm_settings->load_style, 'all' ) ?>><?php _e( 'on every page of your site', 'formidable' ) ?></option>
47
+                <option value="dynamic" <?php selected( $frm_settings->load_style, 'dynamic' ) ?>><?php _e( 'only on applicable pages', 'formidable' ) ?></option>
48
+                <option value="none" <?php selected( $frm_settings->load_style, 'none' ) ?>><?php _e( 'Don\'t use form styling on any page', 'formidable' ) ?></option>
49 49
                 </select>
50 50
             </p>
51 51
 
52 52
             <p>
53 53
 				<label for="frm_use_html">
54
-					<input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked($frm_settings->use_html, 1) ?>	> <?php _e( 'Use HTML5 in forms', 'formidable' ) ?>
54
+					<input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked( $frm_settings->use_html, 1 ) ?>	> <?php _e( 'Use HTML5 in forms', 'formidable' ) ?>
55 55
 				</label>
56 56
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'We recommend using HTML 5 for your forms. It adds some nifty options like placeholders, patterns, and autocomplete.', 'formidable' ) ?>"></span>
57 57
             </p>
58 58
 
59
-            <?php do_action('frm_style_general_settings', $frm_settings); ?>
59
+            <?php do_action( 'frm_style_general_settings', $frm_settings ); ?>
60 60
 
61 61
 			<h3><?php _e( 'User Permissions', 'formidable' ); ?>
62 62
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Select users that are allowed access to Formidable. Without access to View Forms, users will be unable to see the Formidable menu.', 'formidable' ) ?>"></span>
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			</p>
81 81
 
82 82
 			<p><label class="frm_left_label"><?php _e( 'Site Key', 'formidable' ) ?></label>
83
-			<input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr($frm_settings->pubkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
83
+			<input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr( $frm_settings->pubkey ) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
84 84
 
85 85
 			<p><label class="frm_left_label"><?php _e( 'Secret Key', 'formidable' ) ?></label>
86
-			<input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr($frm_settings->privkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
86
+			<input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr( $frm_settings->privkey ) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
87 87
 
88 88
 		    <p><label class="frm_left_label"><?php _e( 'reCAPTCHA Type', 'formidable' ) ?></label>
89 89
 			<select name="frm_re_type" id="frm_re_type">
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 			<select name="frm_re_lang" id="frm_re_lang">
100 100
 				<option value="" <?php selected( $frm_settings->re_lang, '' ) ?>><?php esc_html_e( 'Browser Default', 'formidable' ); ?></option>
101 101
 			    <?php foreach ( $captcha_lang as $lang => $lang_name ) { ?>
102
-				<option value="<?php echo esc_attr($lang) ?>" <?php selected($frm_settings->re_lang, $lang) ?>><?php echo esc_html( $lang_name ) ?></option>
102
+				<option value="<?php echo esc_attr( $lang ) ?>" <?php selected( $frm_settings->re_lang, $lang ) ?>><?php echo esc_html( $lang_name ) ?></option>
103 103
                 <?php } ?>
104 104
             </select></p>
105 105
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			<label class="frm_left_label"><?php _e( 'Success Message', 'formidable' ); ?>
153 153
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'The default message seen after a form is submitted.', 'formidable' ) ?>" ></span>
154 154
 			</label>
155
-            <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr($frm_settings->success_msg) ?>" />
155
+            <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr( $frm_settings->success_msg ) ?>" />
156 156
 		</p>
157 157
 
158 158
 		<p>
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			<input type="text" value="<?php echo esc_attr( $frm_settings->submit_value ) ?>" id="frm_submit_value" name="frm_submit_value" class="frm_with_left_label" />
161 161
 		</p>
162 162
 
163
-        <?php do_action('frm_settings_form', $frm_settings); ?>
163
+        <?php do_action( 'frm_settings_form', $frm_settings ); ?>
164 164
 
165 165
         <?php if ( ! FrmAppHelper::pro_is_installed() ) { ?>
166 166
 			<div class="clear"></div>
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		<?php } ?>
171 171
 
172 172
         <p><label class="frm_left_label"><?php _e( 'Preview Page', 'formidable' ); ?></label>
173
-        <?php FrmAppHelper::wp_pages_dropdown('frm-preview-page-id', $frm_settings->preview_page_id ) ?>
173
+        <?php FrmAppHelper::wp_pages_dropdown( 'frm-preview-page-id', $frm_settings->preview_page_id ) ?>
174 174
         </p>
175 175
 
176 176
 		<p>
Please login to merge, or discard this patch.
classes/models/FrmEntryValues.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 	 * @return array
155 155
 	 */
156 156
 	private function prepare_array_property( $index, $atts ) {
157
-		if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) {
157
+		if ( isset( $atts[$index] ) && ! empty( $atts[$index] ) ) {
158 158
 
159
-			if ( is_array( $atts[ $index ] ) ) {
160
-				$property = $atts[ $index ];
159
+			if ( is_array( $atts[$index] ) ) {
160
+				$property = $atts[$index];
161 161
 			} else {
162
-				$property = explode( ',', $atts[ $index ] );
162
+				$property = explode( ',', $atts[$index] );
163 163
 			}
164 164
 		} else {
165 165
 			$property = array();
@@ -292,6 +292,6 @@  discard block
 block discarded – undo
292 292
 	 * @param stdClass $field
293 293
 	 */
294 294
 	protected function add_field_values( $field ) {
295
-		$this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry, array( 'source' => $this->source ) );
295
+		$this->field_values[$field->id] = new FrmFieldValue( $field, $this->entry, array( 'source' => $this->source ) );
296 296
 	}
297 297
 }
298 298
\ No newline at end of file
Please login to merge, or discard this patch.
classes/models/FrmEntryFormat.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -151,6 +151,7 @@
 block discarded – undo
151 151
 
152 152
 	/**
153 153
 	 * @deprecated 2.04
154
+	 * @param string $val
154 155
 	 */
155 156
 	private static function get_field_value( $atts, &$val ) {
156 157
 		_deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		self::prepare_field_output( $atts, $val );
99 99
 
100 100
 		if ( $atts['format'] != 'text' ) {
101
-			$values[ $f->field_key ] = $val;
101
+			$values[$f->field_key] = $val;
102 102
 			if ( $atts['entry'] && $f->type != 'textarea' ) {
103
-				$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
103
+				$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
104 104
 				if ( $prev_val != $val ) {
105
-					$values[ $f->field_key . '-value' ] = $prev_val;
105
+					$values[$f->field_key . '-value'] = $prev_val;
106 106
 				}
107 107
 			}
108 108
 		} else {
109
-			$values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
109
+			$values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
110 110
 		}
111 111
 	}
112 112
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	private static function fill_missing_fields( $atts, &$values ) {
117 117
 		_deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
118 118
 
119
-		if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
119
+		if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) {
120 120
 			// In case include_blank is set
121
-			$atts['entry']->metas[ $atts['field']->id ] = '';
121
+			$atts['entry']->metas[$atts['field']->id] = '';
122 122
 			$atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) );
123 123
 			self::fill_values_from_entry( $atts, $values );
124 124
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			'type'  => $f->type,
147 147
 		);
148 148
 
149
-		$values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
149
+		$values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
150 150
 	}
151 151
 
152 152
 	/**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 		$f = $atts['field'];
159 159
 		if ( $atts['entry'] ) {
160
-			$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
160
+			$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
161 161
 			$meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type );
162 162
 
163 163
 			//This filter applies to the default-message shortcode and frm-show-entry shortcode only
Please login to merge, or discard this patch.
classes/models/FrmFieldValue.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 * @since 2.04
81 81
 	 */
82 82
 	protected function init_saved_value() {
83
-		if ( isset( $this->entry->metas[ $this->field->id ] ) ) {
84
-			$this->saved_value = $this->entry->metas[ $this->field->id ];
83
+		if ( isset( $this->entry->metas[$this->field->id] ) ) {
84
+			$this->saved_value = $this->entry->metas[$this->field->id];
85 85
 		} else {
86 86
 			$this->saved_value = '';
87 87
 		}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 		if ( $this->source === 'entry_formatter' ) {
156 156
 			// Deprecated frm_email_value hook
157
-			$meta                  = array(
157
+			$meta = array(
158 158
 				'item_id'    => $this->entry->id,
159 159
 				'field_id'   => $this->field->id,
160 160
 				'meta_value' => $this->saved_value,
Please login to merge, or discard this patch.
classes/views/styles/_field-labels.php 1 patch
Spacing   +12 added lines, -12 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('label_color') ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" />
3
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_color' ) ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_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('weight') ) ?>" id="frm_weight">
7
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'weight' ) ) ?>" id="frm_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['weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
10 10
 		<?php } ?>
@@ -12,45 +12,45 @@  discard block
 block discarded – undo
12 12
 </div>
13 13
 <div class="field-group clearfix frm-first-row">
14 14
 	<label><?php _e( 'Size', 'formidable' ) ?></label>
15
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font_size') ) ?>" id="frm_font_size" value="<?php echo esc_attr($style->post_content['font_size']) ?>"  size="3" />
15
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font_size' ) ) ?>" id="frm_font_size" value="<?php echo esc_attr( $style->post_content['font_size'] ) ?>"  size="3" />
16 16
 </div>
17 17
 
18 18
 <div class="field-group clearfix frm_clear">
19 19
 	<label><?php _e( 'Position', 'formidable' ) ?></label>
20
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('position') ) ?>" id="frm_position">
20
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'position' ) ) ?>" id="frm_position">
21 21
 	    <?php foreach ( FrmStylesHelper::get_css_label_positions() as $pos => $pos_label ) { ?>
22
-	        <option value="<?php echo esc_attr( $pos ) ?>" <?php selected($style->post_content['position'], $pos) ?>><?php echo esc_html( $pos_label ) ?></option>
22
+	        <option value="<?php echo esc_attr( $pos ) ?>" <?php selected( $style->post_content['position'], $pos ) ?>><?php echo esc_html( $pos_label ) ?></option>
23 23
 	    <?php } ?>
24 24
 	</select>
25 25
 </div>
26 26
 
27 27
 <div class="field-group clearfix">
28 28
 	<label><?php _e( 'Align', 'formidable' ) ?></label>
29
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('align') ) ?>" id="frm_align">
30
-		<option value="left" <?php selected($style->post_content['align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option>
31
-		<option value="right" <?php selected($style->post_content['align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option>
29
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'align' ) ) ?>" id="frm_align">
30
+		<option value="left" <?php selected( $style->post_content['align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option>
31
+		<option value="right" <?php selected( $style->post_content['align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option>
32 32
 	</select>
33 33
 </div>
34 34
 
35 35
 <div class="field-group clearfix">
36 36
 	<label><?php _e( 'Width', 'formidable' ) ?></label>
37
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('width') ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" />
37
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'width' ) ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" />
38 38
 </div>
39 39
 
40 40
 <div class="field-group clearfix frm_clear">
41 41
 	<label><?php _e( 'Padding', 'formidable' ) ?></label>
42
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_padding') ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" />
42
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_padding' ) ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" />
43 43
 </div>
44 44
 
45 45
 <div class="clear"></div>
46 46
 <h3><?php _e( 'Required Indicator', 'formidable' ) ?></h3>
47 47
 <div class="field-group field-group-border clearfix after-h3">
48 48
 	<label class="background"><?php _e( 'Color', 'formidable' ) ?></label>
49
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('required_color') ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" />
49
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'required_color' ) ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" />
50 50
 </div>
51 51
 <div class="field-group clearfix after-h3">
52 52
 	<label><?php _e( 'Weight', 'formidable' ) ?></label>
53
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('required_weight') ) ?>" id="frm_required_weight">
53
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'required_weight' ) ) ?>" id="frm_required_weight">
54 54
 		<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
55 55
 		<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['required_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
56 56
 		<?php } ?>
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Indentation   +326 added lines, -326 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,26 +139,26 @@  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 );
@@ -172,214 +172,214 @@  discard block
 block discarded – undo
172 172
 			wp_die();
173 173
 		}
174 174
 
175
-        self::include_single_field($field_id, $values);
175
+		self::include_single_field($field_id, $values);
176 176
 
177
-        wp_die();
178
-    }
177
+		wp_die();
178
+	}
179 179
 
180
-    /**
181
-     * Load a single field in the form builder along with all needed variables
182
-     */
183
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
184
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
180
+	/**
181
+	 * Load a single field in the form builder along with all needed variables
182
+	 */
183
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
184
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
185 185
 		$field_name = 'item_meta[' . $field_id . ']';
186
-        $html_id = FrmFieldsHelper::get_html_id($field);
187
-        $id = $form_id ? $form_id : $field['form_id'];
188
-        if ( $field['type'] == 'html' ) {
189
-            $field['stop_filter'] = true;
190
-        }
186
+		$html_id = FrmFieldsHelper::get_html_id($field);
187
+		$id = $form_id ? $form_id : $field['form_id'];
188
+		if ( $field['type'] == 'html' ) {
189
+			$field['stop_filter'] = true;
190
+		}
191 191
 
192 192
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
193 193
 
194
-        return $field;
195
-    }
194
+		return $field;
195
+	}
196 196
 
197
-    public static function destroy() {
197
+	public static function destroy() {
198 198
 		FrmAppHelper::permission_check('frm_edit_forms');
199
-        check_ajax_referer( 'frm_ajax', 'nonce' );
199
+		check_ajax_referer( 'frm_ajax', 'nonce' );
200 200
 
201 201
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
202 202
 		FrmField::destroy( $field_id );
203
-        wp_die();
204
-    }
203
+		wp_die();
204
+	}
205 205
 
206
-    /* Field Options */
206
+	/* Field Options */
207 207
 
208
-    //Add Single Option or Other Option
209
-    public static function add_option() {
208
+	//Add Single Option or Other Option
209
+	public static function add_option() {
210 210
 		FrmAppHelper::permission_check('frm_edit_forms');
211
-        check_ajax_referer( 'frm_ajax', 'nonce' );
211
+		check_ajax_referer( 'frm_ajax', 'nonce' );
212 212
 
213 213
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
214 214
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
215 215
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' );
216 216
 
217
-        $field = FrmField::getOne($id);
217
+		$field = FrmField::getOne($id);
218 218
 
219
-        if ( 'other' == $opt_type ) {
219
+		if ( 'other' == $opt_type ) {
220 220
 			$opt = __( 'Other', 'formidable' );
221
-            $other_val = '';
222
-            $opt_key = 'other_' . $opt_key;
223
-        } else {
221
+			$other_val = '';
222
+			$opt_key = 'other_' . $opt_key;
223
+		} else {
224 224
 			$opt = __( 'New Option', 'formidable' );
225
-        }
226
-        $field_val = $opt;
225
+		}
226
+		$field_val = $opt;
227 227
 
228
-        $field_data = $field;
228
+		$field_data = $field;
229 229
 		$field = (array) $field;
230 230
 		$field['separate_value'] = isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0;
231 231
 		unset( $field_data );
232 232
 
233 233
 		$field_name = 'item_meta[' . $id . ']';
234 234
 		$html_id = FrmFieldsHelper::get_html_id( $field );
235
-        $checked = '';
235
+		$checked = '';
236 236
 
237
-        if ( 'other' == $opt_type ) {
237
+		if ( 'other' == $opt_type ) {
238 238
 			include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
239
-        } else {
239
+		} else {
240 240
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
241
-        }
242
-        wp_die();
243
-    }
241
+		}
242
+		wp_die();
243
+	}
244 244
 
245
-    public static function edit_option() {
245
+	public static function edit_option() {
246 246
 		_deprecated_function( __FUNCTION__, '2.3' );
247
-    }
247
+	}
248 248
 
249
-    public static function delete_option() {
249
+	public static function delete_option() {
250 250
 		_deprecated_function( __FUNCTION__, '2.3' );
251
-    }
251
+	}
252 252
 
253
-    public static function import_choices() {
254
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
253
+	public static function import_choices() {
254
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
255 255
 
256 256
 		$field_id = absint( $_REQUEST['field_id'] );
257 257
 
258
-        global $current_screen, $hook_suffix;
258
+		global $current_screen, $hook_suffix;
259 259
 
260
-        // Catch plugins that include admin-header.php before admin.php completes.
261
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
262
-            $hook_suffix = '';
263
-        	set_current_screen();
264
-        }
260
+		// Catch plugins that include admin-header.php before admin.php completes.
261
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
262
+			$hook_suffix = '';
263
+			set_current_screen();
264
+		}
265 265
 
266
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
267
-            register_admin_color_schemes();
268
-        }
266
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
267
+			register_admin_color_schemes();
268
+		}
269 269
 
270 270
 		$hook_suffix = '';
271 271
 		$admin_body_class = '';
272 272
 
273
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
274
-        	$admin_body_class .= ' folded';
275
-        }
273
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
274
+			$admin_body_class .= ' folded';
275
+		}
276 276
 
277
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
278
-        	$admin_body_class .= ' admin-bar';
279
-        }
277
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
278
+			$admin_body_class .= ' admin-bar';
279
+		}
280 280
 
281
-        if ( is_rtl() ) {
282
-        	$admin_body_class .= ' rtl';
283
-        }
281
+		if ( is_rtl() ) {
282
+			$admin_body_class .= ' rtl';
283
+		}
284 284
 
285
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
286
-        $prepop = array();
287
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
285
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
286
+		$prepop = array();
287
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
288 288
 
289
-        $field = FrmField::getOne($field_id);
289
+		$field = FrmField::getOne($field_id);
290 290
 
291
-        wp_enqueue_script( 'utils' );
291
+		wp_enqueue_script( 'utils' );
292 292
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
293
-        FrmAppHelper::load_admin_wide_js();
293
+		FrmAppHelper::load_admin_wide_js();
294 294
 
295 295
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
296
-        wp_die();
297
-    }
296
+		wp_die();
297
+	}
298 298
 
299
-    public static function import_options() {
299
+	public static function import_options() {
300 300
 		FrmAppHelper::permission_check('frm_edit_forms');
301
-        check_ajax_referer( 'frm_ajax', 'nonce' );
301
+		check_ajax_referer( 'frm_ajax', 'nonce' );
302 302
 
303
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
304
-            return;
305
-        }
303
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
304
+			return;
305
+		}
306 306
 
307 307
 		$field_id = absint( $_POST['field_id'] );
308
-        $field = FrmField::getOne($field_id);
308
+		$field = FrmField::getOne($field_id);
309 309
 
310 310
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
311
-            return;
312
-        }
311
+			return;
312
+		}
313 313
 
314
-        $field = FrmFieldsHelper::setup_edit_vars($field);
314
+		$field = FrmFieldsHelper::setup_edit_vars($field);
315 315
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
316 316
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
317 317
 		$opts = array_map( 'trim', $opts );
318 318
 
319
-        if ( $field['separate_value'] ) {
320
-            foreach ( $opts as $opt_key => $opt ) {
321
-                if ( strpos($opt, '|') !== false ) {
322
-                    $vals = explode('|', $opt);
323
-                    if ( $vals[0] != $vals[1] ) {
324
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
325
-                    }
326
-                    unset($vals);
327
-                }
328
-                unset($opt_key, $opt);
329
-            }
330
-        }
331
-
332
-        //Keep other options after bulk update
333
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
334
-            $other_array = array();
335
-            foreach ( $field['options'] as $opt_key => $opt ) {
319
+		if ( $field['separate_value'] ) {
320
+			foreach ( $opts as $opt_key => $opt ) {
321
+				if ( strpos($opt, '|') !== false ) {
322
+					$vals = explode('|', $opt);
323
+					if ( $vals[0] != $vals[1] ) {
324
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
325
+					}
326
+					unset($vals);
327
+				}
328
+				unset($opt_key, $opt);
329
+			}
330
+		}
331
+
332
+		//Keep other options after bulk update
333
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
334
+			$other_array = array();
335
+			foreach ( $field['options'] as $opt_key => $opt ) {
336 336
 				if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
337 337
 					$other_array[ $opt_key ] = $opt;
338 338
 				}
339
-                unset($opt_key, $opt);
340
-            }
341
-            if ( ! empty($other_array) ) {
342
-                $opts = array_merge( $opts, $other_array);
343
-            }
344
-        }
339
+				unset($opt_key, $opt);
340
+			}
341
+			if ( ! empty($other_array) ) {
342
+				$opts = array_merge( $opts, $other_array);
343
+			}
344
+		}
345 345
 
346
-        $field['options'] = $opts;
346
+		$field['options'] = $opts;
347 347
 
348
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
348
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
349 349
 			$field_name = 'item_meta[' . $field['id'] . ']';
350 350
 
351 351
 			// Get html_id which will be used in single-option.php
352 352
 			$html_id = FrmFieldsHelper::get_html_id( $field );
353 353
 
354 354
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
355
-        } else {
356
-            FrmFieldsHelper::show_single_option($field);
357
-        }
355
+		} else {
356
+			FrmFieldsHelper::show_single_option($field);
357
+		}
358 358
 
359
-        wp_die();
360
-    }
359
+		wp_die();
360
+	}
361 361
 
362
-    public static function update_order() {
362
+	public static function update_order() {
363 363
 		FrmAppHelper::permission_check('frm_edit_forms');
364
-        check_ajax_referer( 'frm_ajax', 'nonce' );
364
+		check_ajax_referer( 'frm_ajax', 'nonce' );
365 365
 
366 366
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
367 367
 		foreach ( (array) $fields as $position => $item ) {
368 368
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
369 369
 		}
370
-        wp_die();
371
-    }
370
+		wp_die();
371
+	}
372 372
 
373 373
 	public static function change_type( $type ) {
374
-        $type_switch = array(
375
-            'scale'     => 'radio',
376
-            '10radio'   => 'radio',
377
-            'rte'       => 'textarea',
378
-            'website'   => 'url',
379
-        );
380
-        if ( isset( $type_switch[ $type ] ) ) {
381
-            $type = $type_switch[ $type ];
382
-        }
374
+		$type_switch = array(
375
+			'scale'     => 'radio',
376
+			'10radio'   => 'radio',
377
+			'rte'       => 'textarea',
378
+			'website'   => 'url',
379
+		);
380
+		if ( isset( $type_switch[ $type ] ) ) {
381
+			$type = $type_switch[ $type ];
382
+		}
383 383
 
384 384
 		$pro_fields = FrmField::pro_field_selection();
385 385
 		$types = array_keys( $pro_fields );
@@ -387,137 +387,137 @@  discard block
 block discarded – undo
387 387
 			$type = 'text';
388 388
 		}
389 389
 
390
-        return $type;
391
-    }
390
+		return $type;
391
+	}
392 392
 
393 393
 	public static function display_field_options( $display ) {
394 394
 		switch ( $display['type'] ) {
395
-            case 'captcha':
396
-                $display['required'] = false;
397
-                $display['invalid'] = true;
398
-                $display['default_blank'] = false;
395
+			case 'captcha':
396
+				$display['required'] = false;
397
+				$display['invalid'] = true;
398
+				$display['default_blank'] = false;
399 399
 				$display['captcha_size'] = true;
400
-            break;
401
-            case 'radio':
402
-                $display['default_blank'] = false;
403
-            break;
404
-            case 'text':
405
-            case 'textarea':
406
-                $display['size'] = true;
407
-                $display['clear_on_focus'] = true;
408
-            break;
409
-            case 'select':
410
-                $display['size'] = true;
411
-            break;
412
-            case 'url':
413
-            case 'website':
414
-            case 'email':
415
-                $display['size'] = true;
416
-                $display['clear_on_focus'] = true;
417
-                $display['invalid'] = true;
418
-        }
419
-
420
-        return $display;
421
-    }
422
-
423
-    public static function input_html( $field, $echo = true ) {
424
-        $class = array(); //$field['type'];
425
-        self::add_input_classes($field, $class);
426
-
427
-        $add_html = array();
428
-        self::add_html_size($field, $add_html);
429
-        self::add_html_length($field, $add_html);
430
-        self::add_html_placeholder($field, $add_html, $class);
400
+			break;
401
+			case 'radio':
402
+				$display['default_blank'] = false;
403
+			break;
404
+			case 'text':
405
+			case 'textarea':
406
+				$display['size'] = true;
407
+				$display['clear_on_focus'] = true;
408
+			break;
409
+			case 'select':
410
+				$display['size'] = true;
411
+			break;
412
+			case 'url':
413
+			case 'website':
414
+			case 'email':
415
+				$display['size'] = true;
416
+				$display['clear_on_focus'] = true;
417
+				$display['invalid'] = true;
418
+		}
419
+
420
+		return $display;
421
+	}
422
+
423
+	public static function input_html( $field, $echo = true ) {
424
+		$class = array(); //$field['type'];
425
+		self::add_input_classes($field, $class);
426
+
427
+		$add_html = array();
428
+		self::add_html_size($field, $add_html);
429
+		self::add_html_length($field, $add_html);
430
+		self::add_html_placeholder($field, $add_html, $class);
431 431
 		self::add_validation_messages( $field, $add_html );
432 432
 
433
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
433
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
434 434
 
435 435
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
436 436
 
437
-        self::add_shortcodes_to_html($field, $add_html);
437
+		self::add_shortcodes_to_html($field, $add_html);
438 438
 
439 439
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
440 440
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
441 441
 
442
-        if ( $echo ) {
443
-            echo $add_html;
444
-        }
442
+		if ( $echo ) {
443
+			echo $add_html;
444
+		}
445 445
 
446
-        return $add_html;
447
-    }
446
+		return $add_html;
447
+	}
448 448
 
449 449
 	private static function add_input_classes( $field, array &$class ) {
450
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
451
-            $class[] = $field['input_class'];
452
-        }
450
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
451
+			$class[] = $field['input_class'];
452
+		}
453 453
 
454
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
455
-            return;
456
-        }
454
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
455
+			return;
456
+		}
457 457
 
458
-        if ( isset($field['size']) && $field['size'] > 0 ) {
459
-            $class[] = 'auto_width';
460
-        }
461
-    }
458
+		if ( isset($field['size']) && $field['size'] > 0 ) {
459
+			$class[] = 'auto_width';
460
+		}
461
+	}
462 462
 
463 463
 	private static function add_html_size( $field, array &$add_html ) {
464 464
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) {
465
-            return;
466
-        }
465
+			return;
466
+		}
467 467
 
468
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
469
-            return;
470
-        }
468
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
469
+			return;
470
+		}
471 471
 
472
-        if ( is_numeric($field['size']) ) {
473
-            $field['size'] .= 'px';
474
-        }
472
+		if ( is_numeric($field['size']) ) {
473
+			$field['size'] .= 'px';
474
+		}
475 475
 
476
-        $important = apply_filters('frm_use_important_width', 1, $field);
477
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
476
+		$important = apply_filters('frm_use_important_width', 1, $field);
477
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
478 478
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
479 479
 
480
-        self::add_html_cols($field, $add_html);
481
-    }
480
+		self::add_html_cols($field, $add_html);
481
+	}
482 482
 
483 483
 	private static function add_html_cols( $field, array &$add_html ) {
484 484
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
485
-            return;
486
-        }
485
+			return;
486
+		}
487 487
 
488
-        // convert to cols for textareas
489
-        $calc = array(
490
-            ''      => 9,
491
-            'px'    => 9,
492
-            'rem'   => 0.444,
493
-            'em'    => 0.544,
494
-        );
488
+		// convert to cols for textareas
489
+		$calc = array(
490
+			''      => 9,
491
+			'px'    => 9,
492
+			'rem'   => 0.444,
493
+			'em'    => 0.544,
494
+		);
495 495
 
496
-        // include "col" for valid html
497
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
496
+		// include "col" for valid html
497
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
498 498
 
499
-        if ( ! isset( $calc[ $unit ] ) ) {
500
-            return;
501
-        }
499
+		if ( ! isset( $calc[ $unit ] ) ) {
500
+			return;
501
+		}
502 502
 
503
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
503
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
504 504
 
505 505
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
506
-    }
506
+	}
507 507
 
508 508
 	private static function add_html_length( $field, array &$add_html ) {
509
-        // check for max setting and if this field accepts maxlength
509
+		// check for max setting and if this field accepts maxlength
510 510
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) {
511
-            return;
512
-        }
511
+			return;
512
+		}
513 513
 
514
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
515
-            // don't load on form builder page
516
-            return;
517
-        }
514
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
515
+			// don't load on form builder page
516
+			return;
517
+		}
518 518
 
519 519
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
520
-    }
520
+	}
521 521
 
522 522
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
523 523
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -614,44 +614,44 @@  discard block
 block discarded – undo
614 614
 		}
615 615
 	}
616 616
 
617
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
618
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
619
-            return;
620
-        }
617
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
618
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
619
+			return;
620
+		}
621 621
 
622
-        foreach ( $field['shortcodes'] as $k => $v ) {
623
-            if ( 'opt' === $k ) {
624
-                continue;
625
-            }
622
+		foreach ( $field['shortcodes'] as $k => $v ) {
623
+			if ( 'opt' === $k ) {
624
+				continue;
625
+			}
626 626
 
627
-            if ( is_numeric($k) && strpos($v, '=') ) {
628
-                $add_html[] = $v;
629
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
627
+			if ( is_numeric($k) && strpos($v, '=') ) {
628
+				$add_html[] = $v;
629
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
630 630
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
631
-            } else {
631
+			} else {
632 632
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
633
-            }
634
-
635
-            unset($k, $v);
636
-        }
637
-    }
638
-
639
-    public static function check_value( $opt, $opt_key, $field ) {
640
-        if ( is_array( $opt ) ) {
641
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
642
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
643
-            } else {
644
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
645
-            }
646
-        }
647
-        return $opt;
648
-    }
633
+			}
634
+
635
+			unset($k, $v);
636
+		}
637
+	}
638
+
639
+	public static function check_value( $opt, $opt_key, $field ) {
640
+		if ( is_array( $opt ) ) {
641
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
642
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
643
+			} else {
644
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
645
+			}
646
+		}
647
+		return $opt;
648
+	}
649 649
 
650 650
 	public static function check_label( $opt ) {
651
-        if ( is_array($opt) ) {
652
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
653
-        }
651
+		if ( is_array($opt) ) {
652
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
653
+		}
654 654
 
655
-        return $opt;
656
-    }
655
+		return $opt;
656
+	}
657 657
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 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,7 +172,7 @@  discard block
 block discarded – undo
172 172
 			wp_die();
173 173
 		}
174 174
 
175
-        self::include_single_field($field_id, $values);
175
+        self::include_single_field( $field_id, $values );
176 176
 
177 177
         wp_die();
178 178
     }
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
      * Load a single field in the form builder along with all needed variables
182 182
      */
183 183
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
184
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
184
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
185 185
 		$field_name = 'item_meta[' . $field_id . ']';
186
-        $html_id = FrmFieldsHelper::get_html_id($field);
186
+        $html_id = FrmFieldsHelper::get_html_id( $field );
187 187
         $id = $form_id ? $form_id : $field['form_id'];
188 188
         if ( $field['type'] == 'html' ) {
189 189
             $field['stop_filter'] = true;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     }
196 196
 
197 197
     public static function destroy() {
198
-		FrmAppHelper::permission_check('frm_edit_forms');
198
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
199 199
         check_ajax_referer( 'frm_ajax', 'nonce' );
200 200
 
201 201
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 
208 208
     //Add Single Option or Other Option
209 209
     public static function add_option() {
210
-		FrmAppHelper::permission_check('frm_edit_forms');
210
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
211 211
         check_ajax_referer( 'frm_ajax', 'nonce' );
212 212
 
213 213
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
214 214
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
215 215
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' );
216 216
 
217
-        $field = FrmField::getOne($id);
217
+        $field = FrmField::getOne( $id );
218 218
 
219 219
         if ( 'other' == $opt_type ) {
220 220
 			$opt = __( 'Other', 'formidable' );
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 
285 285
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
286 286
         $prepop = array();
287
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
287
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
288 288
 
289
-        $field = FrmField::getOne($field_id);
289
+        $field = FrmField::getOne( $field_id );
290 290
 
291 291
         wp_enqueue_script( 'utils' );
292 292
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
@@ -297,35 +297,35 @@  discard block
 block discarded – undo
297 297
     }
298 298
 
299 299
     public static function import_options() {
300
-		FrmAppHelper::permission_check('frm_edit_forms');
300
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
301 301
         check_ajax_referer( 'frm_ajax', 'nonce' );
302 302
 
303
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
303
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
304 304
             return;
305 305
         }
306 306
 
307 307
 		$field_id = absint( $_POST['field_id'] );
308
-        $field = FrmField::getOne($field_id);
308
+        $field = FrmField::getOne( $field_id );
309 309
 
310 310
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
311 311
             return;
312 312
         }
313 313
 
314
-        $field = FrmFieldsHelper::setup_edit_vars($field);
314
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
315 315
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
316 316
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
317 317
 		$opts = array_map( 'trim', $opts );
318 318
 
319 319
         if ( $field['separate_value'] ) {
320 320
             foreach ( $opts as $opt_key => $opt ) {
321
-                if ( strpos($opt, '|') !== false ) {
322
-                    $vals = explode('|', $opt);
321
+                if ( strpos( $opt, '|' ) !== false ) {
322
+                    $vals = explode( '|', $opt );
323 323
                     if ( $vals[0] != $vals[1] ) {
324
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
324
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
325 325
                     }
326
-                    unset($vals);
326
+                    unset( $vals );
327 327
                 }
328
-                unset($opt_key, $opt);
328
+                unset( $opt_key, $opt );
329 329
             }
330 330
         }
331 331
 
@@ -334,12 +334,12 @@  discard block
 block discarded – undo
334 334
             $other_array = array();
335 335
             foreach ( $field['options'] as $opt_key => $opt ) {
336 336
 				if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
337
-					$other_array[ $opt_key ] = $opt;
337
+					$other_array[$opt_key] = $opt;
338 338
 				}
339
-                unset($opt_key, $opt);
339
+                unset( $opt_key, $opt );
340 340
             }
341
-            if ( ! empty($other_array) ) {
342
-                $opts = array_merge( $opts, $other_array);
341
+            if ( ! empty( $other_array ) ) {
342
+                $opts = array_merge( $opts, $other_array );
343 343
             }
344 344
         }
345 345
 
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
 
354 354
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
355 355
         } else {
356
-            FrmFieldsHelper::show_single_option($field);
356
+            FrmFieldsHelper::show_single_option( $field );
357 357
         }
358 358
 
359 359
         wp_die();
360 360
     }
361 361
 
362 362
     public static function update_order() {
363
-		FrmAppHelper::permission_check('frm_edit_forms');
363
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
364 364
         check_ajax_referer( 'frm_ajax', 'nonce' );
365 365
 
366 366
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
             'rte'       => 'textarea',
378 378
             'website'   => 'url',
379 379
         );
380
-        if ( isset( $type_switch[ $type ] ) ) {
381
-            $type = $type_switch[ $type ];
380
+        if ( isset( $type_switch[$type] ) ) {
381
+            $type = $type_switch[$type];
382 382
         }
383 383
 
384 384
 		$pro_fields = FrmField::pro_field_selection();
@@ -422,19 +422,19 @@  discard block
 block discarded – undo
422 422
 
423 423
     public static function input_html( $field, $echo = true ) {
424 424
         $class = array(); //$field['type'];
425
-        self::add_input_classes($field, $class);
425
+        self::add_input_classes( $field, $class );
426 426
 
427 427
         $add_html = array();
428
-        self::add_html_size($field, $add_html);
429
-        self::add_html_length($field, $add_html);
430
-        self::add_html_placeholder($field, $add_html, $class);
428
+        self::add_html_size( $field, $add_html );
429
+        self::add_html_length( $field, $add_html );
430
+        self::add_html_placeholder( $field, $add_html, $class );
431 431
 		self::add_validation_messages( $field, $add_html );
432 432
 
433
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
433
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
434 434
 
435 435
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
436 436
 
437
-        self::add_shortcodes_to_html($field, $add_html);
437
+        self::add_shortcodes_to_html( $field, $add_html );
438 438
 
439 439
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
440 440
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
     }
448 448
 
449 449
 	private static function add_input_classes( $field, array &$class ) {
450
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
450
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
451 451
             $class[] = $field['input_class'];
452 452
         }
453 453
 
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
             return;
456 456
         }
457 457
 
458
-        if ( isset($field['size']) && $field['size'] > 0 ) {
458
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
459 459
             $class[] = 'auto_width';
460 460
         }
461 461
     }
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
             return;
466 466
         }
467 467
 
468
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
468
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
469 469
             return;
470 470
         }
471 471
 
472
-        if ( is_numeric($field['size']) ) {
472
+        if ( is_numeric( $field['size'] ) ) {
473 473
             $field['size'] .= 'px';
474 474
         }
475 475
 
476
-        $important = apply_filters('frm_use_important_width', 1, $field);
476
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
477 477
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
478 478
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
479 479
 
480
-        self::add_html_cols($field, $add_html);
480
+        self::add_html_cols( $field, $add_html );
481 481
     }
482 482
 
483 483
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -494,13 +494,13 @@  discard block
 block discarded – undo
494 494
         );
495 495
 
496 496
         // include "col" for valid html
497
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
497
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
498 498
 
499
-        if ( ! isset( $calc[ $unit ] ) ) {
499
+        if ( ! isset( $calc[$unit] ) ) {
500 500
             return;
501 501
         }
502 502
 
503
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
503
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
504 504
 
505 505
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
506 506
     }
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
             return;
512 512
         }
513 513
 
514
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
514
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
515 515
             // don't load on form builder page
516 516
             return;
517 517
         }
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 	private static function add_placeholder_to_input( $field, &$add_html ) {
592 592
 		if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) {
593 593
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
594
-			wp_enqueue_script('jquery-placeholder');
594
+			wp_enqueue_script( 'jquery-placeholder' );
595 595
 		}
596 596
 	}
597 597
 
@@ -624,15 +624,15 @@  discard block
 block discarded – undo
624 624
                 continue;
625 625
             }
626 626
 
627
-            if ( is_numeric($k) && strpos($v, '=') ) {
627
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
628 628
                 $add_html[] = $v;
629
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
630
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
629
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
630
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
631 631
             } else {
632
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
632
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
633 633
             }
634 634
 
635
-            unset($k, $v);
635
+            unset( $k, $v );
636 636
         }
637 637
     }
638 638
 
@@ -648,8 +648,8 @@  discard block
 block discarded – undo
648 648
     }
649 649
 
650 650
 	public static function check_label( $opt ) {
651
-        if ( is_array($opt) ) {
652
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
651
+        if ( is_array( $opt ) ) {
652
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
653 653
         }
654 654
 
655 655
         return $opt;
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Spacing   +72 added lines, -72 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
 
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
     public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
         $values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11
-			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
11
+			$values[$var] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12 12
         }
13 13
 
14 14
         $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
15
+        if ( empty( $fields ) ) {
16
+            return apply_filters( 'frm_setup_new_entry', $values );
17 17
         }
18 18
 
19 19
         foreach ( (array) $fields as $field ) {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                 'default_value' => $field->default_value,
27 27
                 'name' => $field->name,
28 28
                 'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
30 30
                 'options' => $field->options,
31 31
                 'required' => $field->required,
32 32
                 'field_key' => $field->field_key,
@@ -37,43 +37,43 @@  discard block
 block discarded – undo
37 37
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
38 38
             );
39 39
 
40
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
41 41
             $opt_defaults['required_indicator'] = '';
42 42
 			$opt_defaults['original_type'] = $field->type;
43 43
 
44 44
 			foreach ( $opt_defaults as $opt => $default_opt ) {
45
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
46
-                unset($opt, $default_opt);
45
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
46
+                unset( $opt, $default_opt );
47 47
             }
48 48
 
49
-            unset($opt_defaults);
49
+            unset( $opt_defaults );
50 50
 
51 51
             if ( $field_array['custom_html'] == '' ) {
52
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
53 53
             }
54 54
 
55
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
56 56
             $field_array = array_merge( $field->field_options, $field_array );
57 57
 
58 58
             $values['fields'][] = $field_array;
59 59
 
60
-            if ( ! $form || ! isset($form->id) ) {
61
-                $form = FrmForm::getOne($field->form_id);
60
+            if ( ! $form || ! isset( $form->id ) ) {
61
+                $form = FrmForm::getOne( $field->form_id );
62 62
             }
63 63
         }
64 64
 
65
-        $form->options = maybe_unserialize($form->options);
66
-        if ( is_array($form->options) ) {
65
+        $form->options = maybe_unserialize( $form->options );
66
+        if ( is_array( $form->options ) ) {
67 67
             foreach ( $form->options as $opt => $value ) {
68
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
69
-                unset($opt, $value);
68
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
69
+                unset( $opt, $value );
70 70
             }
71 71
         }
72 72
 
73 73
 		$form_defaults = FrmFormsHelper::get_default_opts();
74 74
 
75 75
 		$frm_settings = FrmAppHelper::get_settings();
76
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
76
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
77 77
 
78 78
 		$values = array_merge( $form_defaults, $values );
79 79
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		}
121 121
 
122 122
 		if ( ! is_array( $new_value ) ) {
123
-			$new_value = str_replace('"', '&quot;', $new_value);
123
+			$new_value = str_replace( '"', '&quot;', $new_value );
124 124
 		}
125 125
 
126 126
 		return $new_value;
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 		if ( $_POST ) {
140 140
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
141 141
 			if ( $repeating ) {
142
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
142
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
143 143
 					$value_is_posted = true;
144 144
 				}
145
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
145
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
146 146
 				$value_is_posted = true;
147 147
 			}
148 148
 		}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
154 154
         $values['form_id'] = $record->form_id;
155 155
         $values['is_draft'] = $record->is_draft;
156
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
156
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
157 157
     }
158 158
 
159 159
     public static function get_admin_params( $form = null ) {
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
     }
183 183
 
184 184
 	public static function replace_default_message( $message, $atts ) {
185
-        if ( strpos($message, '[default-message') === false &&
186
-            strpos($message, '[default_message') === false &&
185
+        if ( strpos( $message, '[default-message' ) === false &&
186
+            strpos( $message, '[default_message' ) === false &&
187 187
             ! empty( $message ) ) {
188 188
             return $message;
189 189
         }
190 190
 
191
-        if ( empty($message) ) {
191
+        if ( empty( $message ) ) {
192 192
             $message = '[default-message]';
193 193
         }
194 194
 
195
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
195
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
196 196
 
197 197
         foreach ( $shortcodes[0] as $short_key => $tag ) {
198
-			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
198
+			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
199 199
 			if ( ! empty( $add_atts ) ) {
200
-                $this_atts = array_merge($atts, $add_atts);
200
+                $this_atts = array_merge( $atts, $add_atts );
201 201
             } else {
202 202
                 $this_atts = $atts;
203 203
             }
@@ -205,32 +205,32 @@  discard block
 block discarded – undo
205 205
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
206 206
 
207 207
             // Add the default message
208
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
208
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
209 209
         }
210 210
 
211 211
         return $message;
212 212
     }
213 213
 
214 214
 	public static function prepare_display_value( $entry, $field, $atts ) {
215
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
215
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
216 216
 
217 217
         if ( FrmAppHelper::pro_is_installed() ) {
218 218
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
219 219
         }
220 220
 
221
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
222
-            return self::display_value($field_value, $field, $atts);
221
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
222
+            return self::display_value( $field_value, $field, $atts );
223 223
         }
224 224
 
225 225
         // this is an embeded form
226 226
         $val = '';
227 227
 
228
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
228
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
229 229
             //this is a repeating section
230 230
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
231 231
         } else {
232 232
             // get all values for this field
233
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
233
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
234 234
 
235 235
             if ( $child_values ) {
236 236
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 	    $field_value = array();
241 241
 
242
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
242
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
243 243
             return $val;
244 244
         }
245 245
 
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
             $atts['post_id'] = $child_entry->post_id;
249 249
 
250 250
             // get the value for this field -- check for post values as well
251
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
251
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
252 252
 
253 253
             if ( $entry_val ) {
254 254
                 // foreach entry get display_value
255
-                $field_value[] = self::display_value($entry_val, $field, $atts);
255
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
256 256
             }
257 257
 
258
-            unset($child_entry);
258
+            unset( $child_entry );
259 259
         }
260 260
 
261
-        $val = implode(', ', (array) $field_value );
261
+        $val = implode( ', ', (array) $field_value );
262 262
 		$val = wp_kses_post( $val );
263 263
 
264 264
         return $val;
@@ -278,22 +278,22 @@  discard block
 block discarded – undo
278 278
         );
279 279
 
280 280
         $atts = wp_parse_args( $atts, $defaults );
281
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
281
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
282 282
 
283
-        if ( ! isset($field->field_options['post_field']) ) {
283
+        if ( ! isset( $field->field_options['post_field'] ) ) {
284 284
             $field->field_options['post_field'] = '';
285 285
         }
286 286
 
287
-        if ( ! isset($field->field_options['custom_field']) ) {
287
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
288 288
             $field->field_options['custom_field'] = '';
289 289
         }
290 290
 
291 291
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
292 292
             $atts['pre_truncate'] = $atts['truncate'];
293 293
             $atts['truncate'] = true;
294
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
294
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
295 295
 
296
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
296
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
297 297
             $atts['truncate'] = $atts['pre_truncate'];
298 298
         }
299 299
 
@@ -301,39 +301,39 @@  discard block
 block discarded – undo
301 301
             return $value;
302 302
         }
303 303
 
304
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
304
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
305 305
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
306 306
 
307 307
         $new_value = '';
308 308
 
309
-        if ( is_array($value) && $atts['type'] != 'file' ) {
309
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
310 310
             foreach ( $value as $val ) {
311
-                if ( is_array($val) ) {
311
+                if ( is_array( $val ) ) {
312 312
 					//TODO: add options for display (li or ,)
313
-                    $new_value .= implode($atts['sep'], $val);
313
+                    $new_value .= implode( $atts['sep'], $val );
314 314
                     if ( $atts['type'] != 'data' ) {
315 315
                         $new_value .= '<br/>';
316 316
                     }
317 317
                 }
318
-                unset($val);
318
+                unset( $val );
319 319
             }
320 320
         }
321 321
 
322
-        if ( ! empty($new_value) ) {
322
+        if ( ! empty( $new_value ) ) {
323 323
             $value = $new_value;
324
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
325
-            $value = implode($atts['sep'], $value);
324
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
325
+            $value = implode( $atts['sep'], $value );
326 326
         }
327 327
 
328 328
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
329
-            $value = FrmAppHelper::truncate($value, 50);
329
+            $value = FrmAppHelper::truncate( $value, 50 );
330 330
         }
331 331
 
332 332
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
333 333
 			$value = wp_kses_post( $value );
334 334
 		}
335 335
 
336
-        return apply_filters('frm_display_value', $value, $field, $atts);
336
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
337 337
     }
338 338
 
339 339
 	public static function set_posted_value( $field, $value, $args ) {
@@ -341,20 +341,20 @@  discard block
 block discarded – undo
341 341
         if ( isset( $args['other'] ) && $args['other'] ) {
342 342
             $value = $args['temp_value'];
343 343
         }
344
-        if ( empty($args['parent_field_id']) ) {
345
-            $_POST['item_meta'][ $field->id ] = $value;
344
+        if ( empty( $args['parent_field_id'] ) ) {
345
+            $_POST['item_meta'][$field->id] = $value;
346 346
         } else {
347
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
347
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
348 348
         }
349 349
     }
350 350
 
351 351
 	public static function get_posted_value( $field, &$value, $args ) {
352 352
 		$field_id = is_object( $field ) ? $field->id : $field;
353 353
 
354
-        if ( empty($args['parent_field_id']) ) {
355
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
354
+        if ( empty( $args['parent_field_id'] ) ) {
355
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
356 356
         } else {
357
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
357
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
358 358
         }
359 359
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
360 360
 		$value = stripslashes_deep( $value );
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
         self::set_other_repeating_vals( $field, $value, $args );
380 380
 
381 381
         // Check if there are any posted "Other" values
382
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
382
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
383 383
 
384 384
             // Save original value
385 385
             $args['temp_value'] = $value;
386 386
             $args['other'] = true;
387
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
387
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
388 388
 
389 389
             // Set the validation value now
390 390
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
         }
407 407
 
408 408
         // Check if there are any other posted "other" values for this field
409
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
409
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
410 410
             // Save original value
411 411
             $args['temp_value'] = $value;
412 412
             $args['other'] = true;
413 413
 
414
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
414
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
415 415
 
416 416
             // Set the validation value now
417 417
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -443,27 +443,27 @@  discard block
 block discarded – undo
443 443
             }
444 444
         } else {
445 445
 			// Radio and dropdowns
446
-            $other_key = array_filter( array_keys($field->options), 'is_string');
446
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
447 447
             $other_key = reset( $other_key );
448 448
 
449 449
             // Multi-select dropdown
450 450
             if ( is_array( $value ) ) {
451
-                $o_key = array_search( $field->options[ $other_key ], $value );
451
+                $o_key = array_search( $field->options[$other_key], $value );
452 452
 
453 453
 				if ( $o_key !== false ) {
454 454
 					// Modify the original value so other key will be preserved
455
-					$value[ $other_key ] = $value[ $o_key ];
455
+					$value[$other_key] = $value[$o_key];
456 456
 
457 457
 					// By default, the array keys will be numeric for multi-select dropdowns
458 458
 					// If going backwards and forwards between pages, the array key will match the other key
459 459
 					if ( $o_key != $other_key ) {
460
-						unset( $value[ $o_key ] );
460
+						unset( $value[$o_key] );
461 461
 					}
462 462
 
463 463
 					$args['temp_value'] = $value;
464
-					$value[ $other_key ] = reset( $other_vals );
464
+					$value[$other_key] = reset( $other_vals );
465 465
 				}
466
-            } else if ( $field->options[ $other_key ] == $value ) {
466
+            } else if ( $field->options[$other_key] == $value ) {
467 467
                 $value = $other_vals;
468 468
             }
469 469
         }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 				$content .= "\n\n";
483 483
 			}
484 484
 
485
-			if ( is_array($val) ) {
485
+			if ( is_array( $val ) ) {
486 486
 				$val = FrmAppHelper::array_flatten( $val );
487 487
 				$val = implode( ', ', $val );
488 488
 			}
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 		preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
547 547
 
548 548
 		// see how many we have
549
-		$i = count($matches['browser']);
549
+		$i = count( $matches['browser'] );
550 550
 
551 551
 		if ( $i > 1 ) {
552 552
 			//we will have two since we are not using 'other' argument yet
Please login to merge, or discard this patch.
Indentation   +289 added lines, -289 removed lines patch added patch discarded remove patch
@@ -5,70 +5,70 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		$values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11 11
 			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12
-        }
12
+		}
13 13
 
14
-        $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
17
-        }
14
+		$values['fields'] = array();
15
+		if ( empty($fields) ) {
16
+			return apply_filters('frm_setup_new_entry', $values);
17
+		}
18 18
 
19
-        foreach ( (array) $fields as $field ) {
19
+		foreach ( (array) $fields as $field ) {
20 20
 			self::prepare_field_default_value( $field );
21
-            $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
22
-
23
-            $field_array = array(
24
-                'id' => $field->id,
25
-                'value' => $new_value,
26
-                'default_value' => $field->default_value,
27
-                'name' => $field->name,
28
-                'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
-                'options' => $field->options,
31
-                'required' => $field->required,
32
-                'field_key' => $field->field_key,
33
-                'field_order' => $field->field_order,
34
-                'form_id' => $field->form_id,
21
+			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
22
+
23
+			$field_array = array(
24
+				'id' => $field->id,
25
+				'value' => $new_value,
26
+				'default_value' => $field->default_value,
27
+				'name' => $field->name,
28
+				'description' => $field->description,
29
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
+				'options' => $field->options,
31
+				'required' => $field->required,
32
+				'field_key' => $field->field_key,
33
+				'field_order' => $field->field_order,
34
+				'form_id' => $field->form_id,
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36
-	            'reset_value' => $reset,
36
+				'reset_value' => $reset,
37 37
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
38
-            );
38
+			);
39 39
 
40
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
41
-            $opt_defaults['required_indicator'] = '';
40
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
41
+			$opt_defaults['required_indicator'] = '';
42 42
 			$opt_defaults['original_type'] = $field->type;
43 43
 
44 44
 			foreach ( $opt_defaults as $opt => $default_opt ) {
45
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
46
-                unset($opt, $default_opt);
47
-            }
45
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
46
+				unset($opt, $default_opt);
47
+			}
48 48
 
49
-            unset($opt_defaults);
49
+			unset($opt_defaults);
50 50
 
51
-            if ( $field_array['custom_html'] == '' ) {
52
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
53
-            }
51
+			if ( $field_array['custom_html'] == '' ) {
52
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
53
+			}
54 54
 
55
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
56
-            $field_array = array_merge( $field->field_options, $field_array );
55
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
56
+			$field_array = array_merge( $field->field_options, $field_array );
57 57
 
58
-            $values['fields'][] = $field_array;
58
+			$values['fields'][] = $field_array;
59 59
 
60
-            if ( ! $form || ! isset($form->id) ) {
61
-                $form = FrmForm::getOne($field->form_id);
62
-            }
63
-        }
60
+			if ( ! $form || ! isset($form->id) ) {
61
+				$form = FrmForm::getOne($field->form_id);
62
+			}
63
+		}
64 64
 
65
-        $form->options = maybe_unserialize($form->options);
66
-        if ( is_array($form->options) ) {
67
-            foreach ( $form->options as $opt => $value ) {
68
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
69
-                unset($opt, $value);
70
-            }
71
-        }
65
+		$form->options = maybe_unserialize($form->options);
66
+		if ( is_array($form->options) ) {
67
+			foreach ( $form->options as $opt => $value ) {
68
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
69
+				unset($opt, $value);
70
+			}
71
+		}
72 72
 
73 73
 		$form_defaults = FrmFormsHelper::get_default_opts();
74 74
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		$values = array_merge( $form_defaults, $values );
79 79
 
80 80
 		return apply_filters( 'frm_setup_new_entry', $values );
81
-    }
81
+	}
82 82
 
83 83
 	/**
84 84
 	 * @since 2.05
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 
95 95
 	/**
96
-	* Set the value for each field
97
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
98
-	*
99
-	* @since 2.0.13
100
-	*
101
-	* @param object $field - this is passed by reference since it is an object
102
-	* @param boolean $reset
103
-	* @param array $args
104
-	* @return string|array $new_value
105
-	*/
96
+	 * Set the value for each field
97
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
98
+	 *
99
+	 * @since 2.0.13
100
+	 *
101
+	 * @param object $field - this is passed by reference since it is an object
102
+	 * @param boolean $reset
103
+	 * @param array $args
104
+	 * @return string|array $new_value
105
+	 */
106 106
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
107 107
 		$new_value = $field->default_value;
108 108
 
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 
129 129
 	/**
130
-	* Check if a field has a posted value
131
-	*
132
-	* @since 2.01.0
133
-	* @param object $field
134
-	* @param array $args
135
-	* @return boolean $value_is_posted
136
-	*/
130
+	 * Check if a field has a posted value
131
+	 *
132
+	 * @since 2.01.0
133
+	 * @param object $field
134
+	 * @param array $args
135
+	 * @return boolean $value_is_posted
136
+	 */
137 137
 	public static function value_is_posted( $field, $args ) {
138 138
 		$value_is_posted = false;
139 139
 		if ( $_POST ) {
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 
152 152
 	public static function setup_edit_vars( $values, $record ) {
153 153
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
154
-        $values['form_id'] = $record->form_id;
155
-        $values['is_draft'] = $record->is_draft;
156
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
157
-    }
154
+		$values['form_id'] = $record->form_id;
155
+		$values['is_draft'] = $record->is_draft;
156
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
157
+	}
158 158
 
159
-    public static function get_admin_params( $form = null ) {
159
+	public static function get_admin_params( $form = null ) {
160 160
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
161 161
 		return FrmForm::set_current_form( $form );
162
-    }
162
+	}
163 163
 
164 164
 	public static function set_current_form( $form_id ) {
165 165
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -171,284 +171,284 @@  discard block
 block discarded – undo
171 171
 		return FrmForm::get_current_form( $form_id );
172 172
 	}
173 173
 
174
-    public static function get_current_form_id() {
174
+	public static function get_current_form_id() {
175 175
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
176 176
 		return FrmForm::get_current_form_id();
177
-    }
177
+	}
178 178
 
179
-    public static function maybe_get_entry( &$entry ) {
179
+	public static function maybe_get_entry( &$entry ) {
180 180
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
181 181
 		FrmEntry::maybe_get_entry( $entry );
182
-    }
182
+	}
183 183
 
184 184
 	public static function replace_default_message( $message, $atts ) {
185
-        if ( strpos($message, '[default-message') === false &&
186
-            strpos($message, '[default_message') === false &&
187
-            ! empty( $message ) ) {
188
-            return $message;
189
-        }
185
+		if ( strpos($message, '[default-message') === false &&
186
+			strpos($message, '[default_message') === false &&
187
+			! empty( $message ) ) {
188
+			return $message;
189
+		}
190 190
 
191
-        if ( empty($message) ) {
192
-            $message = '[default-message]';
193
-        }
191
+		if ( empty($message) ) {
192
+			$message = '[default-message]';
193
+		}
194 194
 
195
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
195
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
196 196
 
197
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
197
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
198 198
 			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
199 199
 			if ( ! empty( $add_atts ) ) {
200
-                $this_atts = array_merge($atts, $add_atts);
201
-            } else {
202
-                $this_atts = $atts;
203
-            }
200
+				$this_atts = array_merge($atts, $add_atts);
201
+			} else {
202
+				$this_atts = $atts;
203
+			}
204 204
 
205 205
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
206 206
 
207
-            // Add the default message
208
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
209
-        }
207
+			// Add the default message
208
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
209
+		}
210 210
 
211
-        return $message;
212
-    }
211
+		return $message;
212
+	}
213 213
 
214 214
 	public static function prepare_display_value( $entry, $field, $atts ) {
215 215
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
216 216
 
217
-        if ( FrmAppHelper::pro_is_installed() ) {
217
+		if ( FrmAppHelper::pro_is_installed() ) {
218 218
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
219
-        }
219
+		}
220 220
 
221
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
222
-            return self::display_value($field_value, $field, $atts);
223
-        }
221
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
222
+			return self::display_value($field_value, $field, $atts);
223
+		}
224 224
 
225
-        // this is an embeded form
226
-        $val = '';
225
+		// this is an embeded form
226
+		$val = '';
227 227
 
228
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
229
-            //this is a repeating section
228
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
229
+			//this is a repeating section
230 230
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
231
-        } else {
232
-            // get all values for this field
233
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
231
+		} else {
232
+			// get all values for this field
233
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
234 234
 
235
-            if ( $child_values ) {
236
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
237
-	        }
238
-	    }
235
+			if ( $child_values ) {
236
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
237
+			}
238
+		}
239 239
 
240
-	    $field_value = array();
240
+		$field_value = array();
241 241
 
242
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
243
-            return $val;
244
-        }
242
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
243
+			return $val;
244
+		}
245 245
 
246
-        foreach ( $child_entries as $child_entry ) {
247
-            $atts['item_id'] = $child_entry->id;
248
-            $atts['post_id'] = $child_entry->post_id;
246
+		foreach ( $child_entries as $child_entry ) {
247
+			$atts['item_id'] = $child_entry->id;
248
+			$atts['post_id'] = $child_entry->post_id;
249 249
 
250
-            // get the value for this field -- check for post values as well
251
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
250
+			// get the value for this field -- check for post values as well
251
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
252 252
 
253
-            if ( $entry_val ) {
254
-                // foreach entry get display_value
255
-                $field_value[] = self::display_value($entry_val, $field, $atts);
256
-            }
253
+			if ( $entry_val ) {
254
+				// foreach entry get display_value
255
+				$field_value[] = self::display_value($entry_val, $field, $atts);
256
+			}
257 257
 
258
-            unset($child_entry);
259
-        }
258
+			unset($child_entry);
259
+		}
260 260
 
261
-        $val = implode(', ', (array) $field_value );
261
+		$val = implode(', ', (array) $field_value );
262 262
 		$val = wp_kses_post( $val );
263 263
 
264
-        return $val;
265
-    }
264
+		return $val;
265
+	}
266 266
 
267
-    /**
268
-     * Prepare the saved value for display
269
-     * @return string
270
-     */
267
+	/**
268
+	 * Prepare the saved value for display
269
+	 * @return string
270
+	 */
271 271
 	public static function display_value( $value, $field, $atts = array() ) {
272 272
 
273
-        $defaults = array(
274
-            'type' => '', 'html' => false, 'show_filename' => true,
275
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
276
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
273
+		$defaults = array(
274
+			'type' => '', 'html' => false, 'show_filename' => true,
275
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
276
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
277 277
 			'return_array' => false,
278
-        );
278
+		);
279 279
 
280
-        $atts = wp_parse_args( $atts, $defaults );
281
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
280
+		$atts = wp_parse_args( $atts, $defaults );
281
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
282 282
 
283
-        if ( ! isset($field->field_options['post_field']) ) {
284
-            $field->field_options['post_field'] = '';
285
-        }
283
+		if ( ! isset($field->field_options['post_field']) ) {
284
+			$field->field_options['post_field'] = '';
285
+		}
286 286
 
287
-        if ( ! isset($field->field_options['custom_field']) ) {
288
-            $field->field_options['custom_field'] = '';
289
-        }
287
+		if ( ! isset($field->field_options['custom_field']) ) {
288
+			$field->field_options['custom_field'] = '';
289
+		}
290 290
 
291
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
292
-            $atts['pre_truncate'] = $atts['truncate'];
293
-            $atts['truncate'] = true;
294
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
291
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
292
+			$atts['pre_truncate'] = $atts['truncate'];
293
+			$atts['truncate'] = true;
294
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
295 295
 
296
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
297
-            $atts['truncate'] = $atts['pre_truncate'];
298
-        }
296
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
297
+			$atts['truncate'] = $atts['pre_truncate'];
298
+		}
299 299
 
300
-        if ( $value == '' ) {
301
-            return $value;
302
-        }
300
+		if ( $value == '' ) {
301
+			return $value;
302
+		}
303 303
 
304
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
304
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
305 305
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
306 306
 
307
-        $new_value = '';
307
+		$new_value = '';
308 308
 
309
-        if ( is_array($value) && $atts['type'] != 'file' ) {
310
-            foreach ( $value as $val ) {
311
-                if ( is_array($val) ) {
309
+		if ( is_array($value) && $atts['type'] != 'file' ) {
310
+			foreach ( $value as $val ) {
311
+				if ( is_array($val) ) {
312 312
 					//TODO: add options for display (li or ,)
313
-                    $new_value .= implode($atts['sep'], $val);
314
-                    if ( $atts['type'] != 'data' ) {
315
-                        $new_value .= '<br/>';
316
-                    }
317
-                }
318
-                unset($val);
319
-            }
320
-        }
321
-
322
-        if ( ! empty($new_value) ) {
323
-            $value = $new_value;
324
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
325
-            $value = implode($atts['sep'], $value);
326
-        }
327
-
328
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
329
-            $value = FrmAppHelper::truncate($value, 50);
330
-        }
313
+					$new_value .= implode($atts['sep'], $val);
314
+					if ( $atts['type'] != 'data' ) {
315
+						$new_value .= '<br/>';
316
+					}
317
+				}
318
+				unset($val);
319
+			}
320
+		}
321
+
322
+		if ( ! empty($new_value) ) {
323
+			$value = $new_value;
324
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
325
+			$value = implode($atts['sep'], $value);
326
+		}
327
+
328
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
329
+			$value = FrmAppHelper::truncate($value, 50);
330
+		}
331 331
 
332 332
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
333 333
 			$value = wp_kses_post( $value );
334 334
 		}
335 335
 
336
-        return apply_filters('frm_display_value', $value, $field, $atts);
337
-    }
336
+		return apply_filters('frm_display_value', $value, $field, $atts);
337
+	}
338 338
 
339 339
 	public static function set_posted_value( $field, $value, $args ) {
340
-        // If validating a field with "other" opt, set back to prev value now
341
-        if ( isset( $args['other'] ) && $args['other'] ) {
342
-            $value = $args['temp_value'];
343
-        }
344
-        if ( empty($args['parent_field_id']) ) {
345
-            $_POST['item_meta'][ $field->id ] = $value;
346
-        } else {
347
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
348
-        }
349
-    }
340
+		// If validating a field with "other" opt, set back to prev value now
341
+		if ( isset( $args['other'] ) && $args['other'] ) {
342
+			$value = $args['temp_value'];
343
+		}
344
+		if ( empty($args['parent_field_id']) ) {
345
+			$_POST['item_meta'][ $field->id ] = $value;
346
+		} else {
347
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
348
+		}
349
+	}
350 350
 
351 351
 	public static function get_posted_value( $field, &$value, $args ) {
352 352
 		$field_id = is_object( $field ) ? $field->id : $field;
353 353
 
354
-        if ( empty($args['parent_field_id']) ) {
355
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
356
-        } else {
357
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
358
-        }
354
+		if ( empty($args['parent_field_id']) ) {
355
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
356
+		} else {
357
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
358
+		}
359 359
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
360 360
 		$value = stripslashes_deep( $value );
361
-    }
362
-
363
-    /**
364
-    * Check if field has an "Other" option and if any other values are posted
365
-    *
366
-    * @since 2.0
367
-    *
368
-    * @param object $field
369
-    * @param string|array $value
370
-    * @param array $args
371
-    */
372
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
373
-        $args['other'] = false;
374
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
375
-            return;
376
-        }
377
-
378
-        // Get other value for fields in repeating section
379
-        self::set_other_repeating_vals( $field, $value, $args );
380
-
381
-        // Check if there are any posted "Other" values
361
+	}
362
+
363
+	/**
364
+	 * Check if field has an "Other" option and if any other values are posted
365
+	 *
366
+	 * @since 2.0
367
+	 *
368
+	 * @param object $field
369
+	 * @param string|array $value
370
+	 * @param array $args
371
+	 */
372
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
373
+		$args['other'] = false;
374
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
375
+			return;
376
+		}
377
+
378
+		// Get other value for fields in repeating section
379
+		self::set_other_repeating_vals( $field, $value, $args );
380
+
381
+		// Check if there are any posted "Other" values
382 382
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
383 383
 
384
-            // Save original value
385
-            $args['temp_value'] = $value;
386
-            $args['other'] = true;
387
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
388
-
389
-            // Set the validation value now
390
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
391
-        }
392
-    }
393
-
394
-    /**
395
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
396
-    *
397
-    * @since 2.0
398
-    *
399
-    * @param object $field
400
-    * @param string|array $value
401
-    * @param array $args
402
-    */
403
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
404
-        if ( ! $args['parent_field_id'] ) {
405
-            return;
406
-        }
407
-
408
-        // Check if there are any other posted "other" values for this field
384
+			// Save original value
385
+			$args['temp_value'] = $value;
386
+			$args['other'] = true;
387
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
388
+
389
+			// Set the validation value now
390
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
391
+		}
392
+	}
393
+
394
+	/**
395
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
396
+	 *
397
+	 * @since 2.0
398
+	 *
399
+	 * @param object $field
400
+	 * @param string|array $value
401
+	 * @param array $args
402
+	 */
403
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
404
+		if ( ! $args['parent_field_id'] ) {
405
+			return;
406
+		}
407
+
408
+		// Check if there are any other posted "other" values for this field
409 409
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
410
-            // Save original value
411
-            $args['temp_value'] = $value;
412
-            $args['other'] = true;
413
-
414
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
415
-
416
-            // Set the validation value now
417
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
418
-        }
419
-    }
420
-
421
-    /**
422
-    * Modify value used for validation
423
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
424
-    * It also adds any text from the free text fields to the value
425
-    *
426
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
427
-    *
428
-    * @since 2.0
429
-    *
430
-    * @param string|array $value
431
-    * @param string|array $other_vals (usually of posted values)
432
-    * @param object $field
433
-    * @param array $args
434
-    */
435
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
436
-        // Checkboxes and multi-select dropdowns
437
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
438
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
439
-            $value = array_merge( $value, $other_vals );
440
-            $value = array_filter( $value );
441
-            if ( count( $value ) == 0 ) {
442
-                $value = '';
443
-            }
444
-        } else {
410
+			// Save original value
411
+			$args['temp_value'] = $value;
412
+			$args['other'] = true;
413
+
414
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
415
+
416
+			// Set the validation value now
417
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
418
+		}
419
+	}
420
+
421
+	/**
422
+	 * Modify value used for validation
423
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
424
+	 * It also adds any text from the free text fields to the value
425
+	 *
426
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
427
+	 *
428
+	 * @since 2.0
429
+	 *
430
+	 * @param string|array $value
431
+	 * @param string|array $other_vals (usually of posted values)
432
+	 * @param object $field
433
+	 * @param array $args
434
+	 */
435
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
436
+		// Checkboxes and multi-select dropdowns
437
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
438
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
439
+			$value = array_merge( $value, $other_vals );
440
+			$value = array_filter( $value );
441
+			if ( count( $value ) == 0 ) {
442
+				$value = '';
443
+			}
444
+		} else {
445 445
 			// Radio and dropdowns
446
-            $other_key = array_filter( array_keys($field->options), 'is_string');
447
-            $other_key = reset( $other_key );
446
+			$other_key = array_filter( array_keys($field->options), 'is_string');
447
+			$other_key = reset( $other_key );
448 448
 
449
-            // Multi-select dropdown
450
-            if ( is_array( $value ) ) {
451
-                $o_key = array_search( $field->options[ $other_key ], $value );
449
+			// Multi-select dropdown
450
+			if ( is_array( $value ) ) {
451
+				$o_key = array_search( $field->options[ $other_key ], $value );
452 452
 
453 453
 				if ( $o_key !== false ) {
454 454
 					// Modify the original value so other key will be preserved
@@ -463,20 +463,20 @@  discard block
 block discarded – undo
463 463
 					$args['temp_value'] = $value;
464 464
 					$value[ $other_key ] = reset( $other_vals );
465 465
 				}
466
-            } else if ( $field->options[ $other_key ] == $value ) {
467
-                $value = $other_vals;
468
-            }
469
-        }
470
-    }
466
+			} else if ( $field->options[ $other_key ] == $value ) {
467
+				$value = $other_vals;
468
+			}
469
+		}
470
+	}
471 471
 
472 472
 	public static function enqueue_scripts( $params ) {
473 473
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
474 474
 		FrmFormsController::enqueue_scripts( $params );
475 475
 	}
476 476
 
477
-    // Add submitted values to a string for spam checking
477
+	// Add submitted values to a string for spam checking
478 478
 	public static function entry_array_to_string( $values ) {
479
-        $content = '';
479
+		$content = '';
480 480
 		foreach ( $values['item_meta'] as $val ) {
481 481
 			if ( $content != '' ) {
482 482
 				$content .= "\n\n";
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 		}
492 492
 
493 493
 		return $content;
494
-    }
494
+	}
495 495
 
496 496
 	/**
497 497
 	 * Get the browser from the user agent
Please login to merge, or discard this patch.
classes/models/FrmTableHTMLGenerator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		) );
84 84
 
85 85
 		foreach ( $this->style_settings as $key => $setting ) {
86
-			if ( isset( $atts[ $key ] ) && $atts[ $key ] !== '' ) {
87
-				$this->style_settings[ $key ] = $atts[ $key ];
86
+			if ( isset( $atts[$key] ) && $atts[$key] !== '' ) {
87
+				$this->style_settings[$key] = $atts[$key];
88 88
 			}
89 89
 
90 90
 			if ( $this->is_color_setting( $key ) ) {
91
-				$this->style_settings[ $key ] = $this->get_color_markup( $this->style_settings[ $key ] );
91
+				$this->style_settings[$key] = $this->get_color_markup( $this->style_settings[$key] );
92 92
 			}
93 93
 		}
94 94
 	}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return boolean
160 160
 	 */
161
-	private function is_color_setting ( $setting_key ) {
161
+	private function is_color_setting( $setting_key ) {
162 162
 		return strpos( $setting_key, 'color' ) !== false;
163 163
 	}
164 164
 
Please login to merge, or discard this patch.