Completed
Push — master ( 3860cc...10e837 )
by Stephanie
9s
created
classes/views/frm-fields/single-option.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <li id="frm_delete_field_<?php echo esc_attr( $field['id'] ); ?>-<?php echo esc_attr( $opt_key ) ?>_container" class="frm_single_option">
2 2
     <a href="javascript:void(0)" class="frm_single_visible_hover frm_icon_font frm_delete_icon" data-fid="<?php echo esc_attr( $field['id'] ); ?>"> </a>
3 3
     <?php if ( $field['type'] != 'select' ) { ?>
4
-        <input type="<?php echo esc_attr( $field['type'] ) ?>" name="<?php echo esc_attr( $field_name . ( $field['type'] == 'checkbox' ? '[]' : '' ) ); ?>" value="<?php echo esc_attr($field_val) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/>
4
+        <input type="<?php echo esc_attr( $field['type'] ) ?>" name="<?php echo esc_attr( $field_name . ( $field['type'] == 'checkbox' ? '[]' : '' ) ); ?>" value="<?php echo esc_attr( $field_val ) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/>
5 5
     <?php } ?>
6 6
 
7
-	<label class="frm_ipe_field_option field_<?php echo esc_attr( $field['id'] ) ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>"><?php echo ($opt == '') ? __( '(Blank)', 'formidable' ) : $opt ?></label>
7
+	<label class="frm_ipe_field_option field_<?php echo esc_attr( $field['id'] ) ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>"><?php echo ( $opt == '' ) ? __( '(Blank)', 'formidable' ) : $opt ?></label>
8 8
 	<input type="hidden" name="field_options[options_<?php echo esc_attr( $field['id'] ) ?>][<?php echo esc_attr( $opt_key ) ?>][label]" value="<?php echo esc_attr( $opt ) ?>" />
9 9
 
10 10
     <span class="frm_option_key field_<?php echo esc_attr( $field['id'] ) ?>_option_key<?php echo esc_attr( $field['separate_value'] ? '' : ' frm_hidden' ); ?>">
@@ -13,4 +13,4 @@  discard block
 block discarded – undo
13 13
     </span>
14 14
 </li>
15 15
 <?php
16
-unset($field_val, $opt, $opt_key);
16
+unset( $field_val, $opt, $opt_key );
Please login to merge, or discard this patch.
classes/models/FrmStyle.php 2 patches
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStyle {
3
-    public $number = false;	// Unique ID number of the current instance.
3
+    public $number = false; // Unique ID number of the current instance.
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
     public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = pow(36, 6);
16
+        $max_slug_value = pow( 36, 6 );
17 17
         $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
18
+        $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
19 19
 
20 20
         $style = array(
21 21
             'post_type'     => FrmStylesController::$post_type,
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44
- 		if ( empty($id) ) {
44
+ 		if ( empty( $id ) ) {
45 45
  		     $new_style = (array) $this->get_new();
46 46
  		     $all_instances[] = $new_style;
47 47
  		}
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         $action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52
- 			$new_instance = stripslashes_deep( (array) $new_instance);
52
+ 			$new_instance = stripslashes_deep( (array) $new_instance );
53 53
  			$this->id = $new_instance['ID'];
54
- 			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55
-				$all_instances[ $number ] = $new_instance;
54
+ 			if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
55
+				$all_instances[$number] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
57
+ 			    if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) {
58 58
  			        // this style was set to default, so remove default setting on previous default style
59 59
  			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
60
+ 			        $action_ids[] = $this->save( $new_instance );
61 61
  			    }
62 62
 
63 63
  			    // don't continue if not saving this style
@@ -67,33 +67,33 @@  discard block
 block discarded – undo
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+            $new_instance['post_status'] = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
73
+            if ( empty( $id ) ) {
74 74
                 $new_instance['post_name'] = $new_instance['post_title'];
75 75
             }
76 76
 
77 77
             $default_settings = $this->get_defaults();
78 78
 
79 79
             foreach ( $default_settings as $setting => $default ) {
80
-				if ( ! isset( $new_instance['post_content'][ $setting ] ) ) {
81
-					$new_instance['post_content'][ $setting ] = $default;
80
+				if ( ! isset( $new_instance['post_content'][$setting] ) ) {
81
+					$new_instance['post_content'][$setting] = $default;
82 82
 				}
83 83
 
84 84
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
85 85
                     //if is a color
86
-					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
87
-				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
88
-					$new_instance['post_content'][ $setting ] = 0;
86
+					$new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] );
87
+				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) {
88
+					$new_instance['post_content'][$setting] = 0;
89 89
                 } else if ( $setting == 'font' ) {
90
-                	$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
90
+                	$new_instance['post_content'][$setting] = $this->force_balanced_quotation( $new_instance['post_content'][$setting] );
91 91
                 }
92 92
             }
93 93
 
94
-			$all_instances[ $number ] = $new_instance;
94
+			$all_instances[$number] = $new_instance;
95 95
 
96
-            $action_ids[] = $this->save($new_instance);
96
+            $action_ids[] = $this->save( $new_instance );
97 97
 
98 98
  		}
99 99
 
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
      */
108 108
 	public function save_settings() {
109 109
 		$filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
110
-		update_option( 'frm_last_style_update', date('njGi') );
110
+		update_option( 'frm_last_style_update', date( 'njGi' ) );
111 111
 
112
-        if ( ! is_file($filename) ) {
112
+        if ( ! is_file( $filename ) ) {
113 113
             return;
114 114
         }
115 115
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 		$create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) );
121 121
 		$create_file->create_file( $css );
122 122
 
123
-        update_option('frmpro_css', $css);
123
+        update_option( 'frmpro_css', $css );
124 124
 
125
-        set_transient('frmpro_css', $css);
125
+        set_transient( 'frmpro_css', $css );
126 126
 	}
127 127
 
128 128
 	private function get_css_content( $filename ) {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	}
155 155
 
156 156
 	public function destroy( $id ) {
157
-        return wp_delete_post($id);
157
+        return wp_delete_post( $id );
158 158
     }
159 159
 
160 160
     public function get_one() {
@@ -168,19 +168,19 @@  discard block
 block discarded – undo
168 168
             return $style;
169 169
         }
170 170
 
171
-        $style = get_post($this->id);
171
+        $style = get_post( $this->id );
172 172
 
173 173
         if ( ! $style ) {
174 174
             return $style;
175 175
         }
176 176
 
177
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
177
+        $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
178 178
 
179 179
         $default_values = $this->get_defaults();
180 180
 
181 181
         // fill default values
182
-        $style->post_content = $this->override_defaults($style->post_content);
183
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
182
+        $style->post_content = $this->override_defaults( $style->post_content );
183
+        $style->post_content = wp_parse_args( $style->post_content, $default_values );
184 184
 
185 185
         return $style;
186 186
     }
@@ -194,21 +194,21 @@  discard block
 block discarded – undo
194 194
 			'order'       => $order,
195 195
         );
196 196
 
197
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
197
+        $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
198 198
 
199
-        if ( empty($temp_styles) ) {
199
+        if ( empty( $temp_styles ) ) {
200 200
             global $wpdb;
201 201
             // make sure there wasn't a conflict with the query
202 202
 			$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
203
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
203
+            $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
204 204
 
205
-            if ( empty($temp_styles) ) {
205
+            if ( empty( $temp_styles ) ) {
206 206
                 // create a new style if there are none
207 207
          		$new = $this->get_new();
208 208
          		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
209 209
          		$new->menu_order = 1;
210
-         		$new = $this->save( (array) $new);
211
-         		$this->update('default');
210
+         		$new = $this->save( (array) $new );
211
+         		$this->update( 'default' );
212 212
 
213 213
                 $post_atts['include'] = $new;
214 214
 
@@ -232,25 +232,25 @@  discard block
 block discarded – undo
232 232
                 }
233 233
             }
234 234
 
235
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
235
+            $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
236 236
 
237 237
             // fill default values
238
-            $style->post_content = $this->override_defaults($style->post_content);
239
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
238
+            $style->post_content = $this->override_defaults( $style->post_content );
239
+            $style->post_content = wp_parse_args( $style->post_content, $default_values );
240 240
 
241
-			$styles[ $style->ID ] = $style;
241
+			$styles[$style->ID] = $style;
242 242
         }
243 243
 
244 244
         if ( ! $default_style ) {
245
-            $default_style = reset($styles);
246
-			$styles[ $default_style->ID ]->menu_order = 1;
245
+            $default_style = reset( $styles );
246
+			$styles[$default_style->ID]->menu_order = 1;
247 247
         }
248 248
 
249 249
         return $styles;
250 250
     }
251 251
 
252 252
 	public function get_default_style( $styles = null ) {
253
-        if ( ! isset($styles) ) {
253
+        if ( ! isset( $styles ) ) {
254 254
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
255 255
         }
256 256
 
@@ -262,24 +262,24 @@  discard block
 block discarded – undo
262 262
     }
263 263
 
264 264
 	public function override_defaults( $settings ) {
265
-	    if ( ! is_array($settings) ) {
265
+	    if ( ! is_array( $settings ) ) {
266 266
 	        return $settings;
267 267
 	    }
268 268
 
269
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
269
+	    $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
270 270
 
271
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
271
+	    if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
272 272
 	        $settings['form_desc_size'] = $settings['description_font_size'];
273 273
 	        $settings['form_desc_color'] = $settings['description_color'];
274 274
 	        $settings['title_color'] = $settings['label_color'];
275 275
 	    }
276 276
 
277
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
277
+	    if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) {
278 278
 	        $settings['section_color'] = $settings['label_color'];
279 279
 	        $settings['section_border_color'] = $settings['border_color'];
280 280
 	    }
281 281
 
282
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
282
+	    if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) {
283 283
 	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
284 284
 	        $settings['submit_hover_color'] = $settings['submit_text_color'];
285 285
 	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
Please login to merge, or discard this patch.
Indentation   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -1,52 +1,52 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStyle {
3
-    public $number = false;	// Unique ID number of the current instance.
3
+	public $number = false;	// Unique ID number of the current instance.
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7 7
 	 * @param int|string $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10
-        $this->id = $id;
11
-    }
10
+		$this->id = $id;
11
+	}
12 12
 
13
-    public function get_new() {
13
+	public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = pow(36, 6);
17
-        $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
-
20
-        $style = array(
21
-            'post_type'     => FrmStylesController::$post_type,
22
-            'ID'            => '',
23
-            'post_title'    => __( 'New Style', 'formidable' ),
24
-            'post_name'     => $key,
25
-            'post_content'  => $this->get_defaults(),
26
-            'menu_order'    => '',
27
-            'post_status'   => 'publish',
28
-        );
16
+		$max_slug_value = pow(36, 6);
17
+		$min_slug_value = 37; // we want to have at least 2 characters in the slug
18
+		$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
+
20
+		$style = array(
21
+			'post_type'     => FrmStylesController::$post_type,
22
+			'ID'            => '',
23
+			'post_title'    => __( 'New Style', 'formidable' ),
24
+			'post_name'     => $key,
25
+			'post_content'  => $this->get_defaults(),
26
+			'menu_order'    => '',
27
+			'post_status'   => 'publish',
28
+		);
29 29
 
30
-        return (object) $style;
31
-    }
30
+		return (object) $style;
31
+	}
32 32
 
33 33
 	public function save( $settings ) {
34 34
 		return FrmAppHelper::save_settings( $settings, 'frm_styles' );
35
-    }
35
+	}
36 36
 
37 37
 	public function duplicate( $id ) {
38
-        // duplicating is a pro feature
39
-    }
38
+		// duplicating is a pro feature
39
+	}
40 40
 
41
-    public function update( $id = 'default' ) {
41
+	public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44 44
  		if ( empty($id) ) {
45
- 		     $new_style = (array) $this->get_new();
46
- 		     $all_instances[] = $new_style;
45
+ 			 $new_style = (array) $this->get_new();
46
+ 			 $all_instances[] = $new_style;
47 47
  		}
48 48
 
49
-        $action_ids = array();
49
+		$action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52 52
  			$new_instance = stripslashes_deep( (array) $new_instance);
@@ -54,46 +54,46 @@  discard block
 block discarded – undo
54 54
  			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55 55
 				$all_instances[ $number ] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
- 			        // this style was set to default, so remove default setting on previous default style
59
- 			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
61
- 			    }
57
+ 				if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
+ 					// this style was set to default, so remove default setting on previous default style
59
+ 					$new_instance['menu_order'] = 0;
60
+ 					$action_ids[] = $this->save($new_instance);
61
+ 				}
62 62
 
63
- 			    // don't continue if not saving this style
64
- 			    continue;
63
+ 				// don't continue if not saving this style
64
+ 				continue;
65 65
  			}
66 66
 
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+			$new_instance['post_status']  = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
74
-                $new_instance['post_name'] = $new_instance['post_title'];
75
-            }
73
+			if ( empty($id) ) {
74
+				$new_instance['post_name'] = $new_instance['post_title'];
75
+			}
76 76
 
77
-            $default_settings = $this->get_defaults();
77
+			$default_settings = $this->get_defaults();
78 78
 
79
-            foreach ( $default_settings as $setting => $default ) {
79
+			foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( ! isset( $new_instance['post_content'][ $setting ] ) ) {
81 81
 					$new_instance['post_content'][ $setting ] = $default;
82 82
 				}
83 83
 
84 84
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
85
-                    //if is a color
85
+					//if is a color
86 86
 					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
87 87
 				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
88 88
 					$new_instance['post_content'][ $setting ] = 0;
89
-                } else if ( $setting == 'font' ) {
90
-                	$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
91
-                }
92
-            }
89
+				} else if ( $setting == 'font' ) {
90
+					$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
91
+				}
92
+			}
93 93
 
94 94
 			$all_instances[ $number ] = $new_instance;
95 95
 
96
-            $action_ids[] = $this->save($new_instance);
96
+			$action_ids[] = $this->save($new_instance);
97 97
 
98 98
  		}
99 99
 
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
  		return $action_ids;
103 103
  	}
104 104
 
105
-    /**
106
-     * Create static css file
107
-     */
105
+	/**
106
+	 * Create static css file
107
+	 */
108 108
 	public function save_settings() {
109 109
 		$filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
110 110
 		update_option( 'frm_last_style_update', date('njGi') );
111 111
 
112
-        if ( ! is_file($filename) ) {
113
-            return;
114
-        }
112
+		if ( ! is_file($filename) ) {
113
+			return;
114
+		}
115 115
 
116 116
 		$this->clear_cache();
117 117
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 		$create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) );
121 121
 		$create_file->create_file( $css );
122 122
 
123
-        update_option('frmpro_css', $css);
123
+		update_option('frmpro_css', $css);
124 124
 
125
-        set_transient('frmpro_css', $css);
125
+		set_transient('frmpro_css', $css);
126 126
 	}
127 127
 
128 128
 	private function get_css_content( $filename ) {
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
 		$saving = true;
132 132
 		$frm_style = $this;
133 133
 
134
-        ob_start();
135
-        include( $filename );
134
+		ob_start();
135
+		include( $filename );
136 136
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
137
-        ob_end_clean();
137
+		ob_end_clean();
138 138
 
139 139
 		return $css;
140 140
 	}
@@ -154,269 +154,269 @@  discard block
 block discarded – undo
154 154
 	}
155 155
 
156 156
 	public function destroy( $id ) {
157
-        return wp_delete_post($id);
158
-    }
157
+		return wp_delete_post($id);
158
+	}
159 159
 
160
-    public function get_one() {
161
-        if ( 'default' == $this->id ) {
162
-            $style = $this->get_default_style();
163
-            if ( $style ) {
164
-                $this->id = $style->ID;
165
-            } else {
166
-                $this->id = 0;
167
-            }
168
-            return $style;
169
-        }
160
+	public function get_one() {
161
+		if ( 'default' == $this->id ) {
162
+			$style = $this->get_default_style();
163
+			if ( $style ) {
164
+				$this->id = $style->ID;
165
+			} else {
166
+				$this->id = 0;
167
+			}
168
+			return $style;
169
+		}
170 170
 
171
-        $style = get_post($this->id);
171
+		$style = get_post($this->id);
172 172
 
173
-        if ( ! $style ) {
174
-            return $style;
175
-        }
173
+		if ( ! $style ) {
174
+			return $style;
175
+		}
176 176
 
177
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
177
+		$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
178 178
 
179
-        $default_values = $this->get_defaults();
179
+		$default_values = $this->get_defaults();
180 180
 
181
-        // fill default values
182
-        $style->post_content = $this->override_defaults($style->post_content);
183
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
181
+		// fill default values
182
+		$style->post_content = $this->override_defaults($style->post_content);
183
+		$style->post_content = wp_parse_args( $style->post_content, $default_values);
184 184
 
185
-        return $style;
186
-    }
185
+		return $style;
186
+	}
187 187
 
188
-    public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
189
-        $post_atts = array(
188
+	public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
189
+		$post_atts = array(
190 190
 			'post_type'   => FrmStylesController::$post_type,
191 191
 			'post_status' => 'publish',
192 192
 			'numberposts' => $limit,
193 193
 			'orderby'     => $orderby,
194 194
 			'order'       => $order,
195
-        );
195
+		);
196 196
 
197
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
197
+		$temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
198 198
 
199
-        if ( empty($temp_styles) ) {
200
-            global $wpdb;
201
-            // make sure there wasn't a conflict with the query
199
+		if ( empty($temp_styles) ) {
200
+			global $wpdb;
201
+			// make sure there wasn't a conflict with the query
202 202
 			$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
203
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
203
+			$temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
204 204
 
205
-            if ( empty($temp_styles) ) {
206
-                // create a new style if there are none
207
-         		$new = $this->get_new();
205
+			if ( empty($temp_styles) ) {
206
+				// create a new style if there are none
207
+		 		$new = $this->get_new();
208 208
 				$new->post_title = __( 'Formidable Style', 'formidable' );
209 209
 				$new->post_name = $new->post_title;
210
-         		$new->menu_order = 1;
211
-         		$new = $this->save( (array) $new);
212
-         		$this->update('default');
213
-
214
-                $post_atts['include'] = $new;
215
-
216
-                $temp_styles = get_posts( $post_atts );
217
-            }
218
-        }
219
-
220
-        $default_values = $this->get_defaults();
221
-        $default_style = false;
222
-
223
-        $styles = array();
224
-        foreach ( $temp_styles as $style ) {
225
-            $this->id = $style->ID;
226
-            if ( $style->menu_order ) {
227
-                if ( $default_style ) {
228
-                    // only return one default
229
-                    $style->menu_order = 0;
230
-                } else {
231
-                    // check for a default style
232
-                    $default_style = $style->ID;
233
-                }
234
-            }
235
-
236
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
237
-
238
-            // fill default values
239
-            $style->post_content = $this->override_defaults($style->post_content);
240
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
210
+		 		$new->menu_order = 1;
211
+		 		$new = $this->save( (array) $new);
212
+		 		$this->update('default');
213
+
214
+				$post_atts['include'] = $new;
215
+
216
+				$temp_styles = get_posts( $post_atts );
217
+			}
218
+		}
219
+
220
+		$default_values = $this->get_defaults();
221
+		$default_style = false;
222
+
223
+		$styles = array();
224
+		foreach ( $temp_styles as $style ) {
225
+			$this->id = $style->ID;
226
+			if ( $style->menu_order ) {
227
+				if ( $default_style ) {
228
+					// only return one default
229
+					$style->menu_order = 0;
230
+				} else {
231
+					// check for a default style
232
+					$default_style = $style->ID;
233
+				}
234
+			}
235
+
236
+			$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
237
+
238
+			// fill default values
239
+			$style->post_content = $this->override_defaults($style->post_content);
240
+			$style->post_content = wp_parse_args( $style->post_content, $default_values);
241 241
 
242 242
 			$styles[ $style->ID ] = $style;
243
-        }
243
+		}
244 244
 
245
-        if ( ! $default_style ) {
246
-            $default_style = reset($styles);
245
+		if ( ! $default_style ) {
246
+			$default_style = reset($styles);
247 247
 			$styles[ $default_style->ID ]->menu_order = 1;
248
-        }
248
+		}
249 249
 
250
-        return $styles;
251
-    }
250
+		return $styles;
251
+	}
252 252
 
253 253
 	public function get_default_style( $styles = null ) {
254
-        if ( ! isset($styles) ) {
254
+		if ( ! isset($styles) ) {
255 255
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
256
-        }
256
+		}
257 257
 
258
-        foreach ( $styles as $style ) {
259
-            if ( $style->menu_order ) {
260
-                return $style;
261
-            }
262
-        }
263
-    }
258
+		foreach ( $styles as $style ) {
259
+			if ( $style->menu_order ) {
260
+				return $style;
261
+			}
262
+		}
263
+	}
264 264
 
265 265
 	public function override_defaults( $settings ) {
266
-	    if ( ! is_array($settings) ) {
267
-	        return $settings;
268
-	    }
269
-
270
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
271
-
272
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
273
-	        $settings['form_desc_size'] = $settings['description_font_size'];
274
-	        $settings['form_desc_color'] = $settings['description_color'];
275
-	        $settings['title_color'] = $settings['label_color'];
276
-	    }
277
-
278
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
279
-	        $settings['section_color'] = $settings['label_color'];
280
-	        $settings['section_border_color'] = $settings['border_color'];
281
-	    }
282
-
283
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
284
-	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
285
-	        $settings['submit_hover_color'] = $settings['submit_text_color'];
286
-	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
287
-
288
-	        $settings['submit_active_bg_color'] = $settings['submit_bg_color'];
289
-	        $settings['submit_active_color'] = $settings['submit_text_color'];
290
-            $settings['submit_active_border_color'] = $settings['submit_border_color'];
291
-	    }
292
-
293
-	    return $settings;
266
+		if ( ! is_array($settings) ) {
267
+			return $settings;
268
+		}
269
+
270
+		$settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
271
+
272
+		if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
273
+			$settings['form_desc_size'] = $settings['description_font_size'];
274
+			$settings['form_desc_color'] = $settings['description_color'];
275
+			$settings['title_color'] = $settings['label_color'];
276
+		}
277
+
278
+		if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
279
+			$settings['section_color'] = $settings['label_color'];
280
+			$settings['section_border_color'] = $settings['border_color'];
281
+		}
282
+
283
+		if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
284
+			$settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
285
+			$settings['submit_hover_color'] = $settings['submit_text_color'];
286
+			$settings['submit_hover_border_color'] = $settings['submit_border_color'];
287
+
288
+			$settings['submit_active_bg_color'] = $settings['submit_bg_color'];
289
+			$settings['submit_active_color'] = $settings['submit_text_color'];
290
+			$settings['submit_active_border_color'] = $settings['submit_border_color'];
291
+		}
292
+
293
+		return $settings;
294 294
 	}
295 295
 
296 296
 	public function get_defaults() {
297
-        return array(
298
-            'theme_css'         => 'ui-lightness',
299
-            'theme_name'        => 'UI Lightness',
297
+		return array(
298
+			'theme_css'         => 'ui-lightness',
299
+			'theme_name'        => 'UI Lightness',
300 300
 
301 301
 			'center_form'		=> '',
302
-            'form_width'        => '100%',
303
-            'form_align'        => 'left',
304
-            'direction'         => is_rtl() ? 'rtl' : 'ltr',
305
-            'fieldset'          => '0px',
306
-            'fieldset_color'    => '000000',
307
-            'fieldset_padding'  => '0 0 15px 0',
308
-            'fieldset_bg_color' => '',
309
-
310
-            'title_size'        => '20px',
311
-            'title_color'       => '444444',
302
+			'form_width'        => '100%',
303
+			'form_align'        => 'left',
304
+			'direction'         => is_rtl() ? 'rtl' : 'ltr',
305
+			'fieldset'          => '0px',
306
+			'fieldset_color'    => '000000',
307
+			'fieldset_padding'  => '0 0 15px 0',
308
+			'fieldset_bg_color' => '',
309
+
310
+			'title_size'        => '20px',
311
+			'title_color'       => '444444',
312 312
 			'title_margin_top'  => '10px',
313 313
 			'title_margin_bottom' => '10px',
314
-            'form_desc_size'    => '14px',
315
-            'form_desc_color'   => '666666',
314
+			'form_desc_size'    => '14px',
315
+			'form_desc_color'   => '666666',
316 316
 			'form_desc_margin_top' => '10px',
317 317
 			'form_desc_margin_bottom' => '25px',
318 318
 
319
-            'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
320
-            'font_size'         => '14px',
321
-            'label_color'       => '444444',
322
-            'weight'            => 'bold',
323
-            'position'          => 'none',
324
-            'align'             => 'left',
325
-            'width'             => '150px',
326
-            'required_color'    => 'B94A48',
327
-            'required_weight'   => 'bold',
328
-            'label_padding'     => '0 0 3px 0',
329
-
330
-            'description_font_size' => '12px',
331
-            'description_color' => '666666',
332
-            'description_weight' => 'normal',
333
-            'description_style' => 'normal',
334
-            'description_align' => 'left',
319
+			'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
320
+			'font_size'         => '14px',
321
+			'label_color'       => '444444',
322
+			'weight'            => 'bold',
323
+			'position'          => 'none',
324
+			'align'             => 'left',
325
+			'width'             => '150px',
326
+			'required_color'    => 'B94A48',
327
+			'required_weight'   => 'bold',
328
+			'label_padding'     => '0 0 3px 0',
329
+
330
+			'description_font_size' => '12px',
331
+			'description_color' => '666666',
332
+			'description_weight' => 'normal',
333
+			'description_style' => 'normal',
334
+			'description_align' => 'left',
335 335
 			'description_margin' => '0',
336 336
 
337
-            'field_font_size'   => '14px',
338
-            'field_height' 		=> '32px',
339
-            'line_height'		=> 'normal',
340
-            'field_width'       => '100%',
341
-            'auto_width'        => false,
342
-            'field_pad'         => '6px 10px',
343
-            'field_margin'      => '20px',
337
+			'field_font_size'   => '14px',
338
+			'field_height' 		=> '32px',
339
+			'line_height'		=> 'normal',
340
+			'field_width'       => '100%',
341
+			'auto_width'        => false,
342
+			'field_pad'         => '6px 10px',
343
+			'field_margin'      => '20px',
344 344
 			'field_weight' => 'normal',
345
-            'text_color'        => '555555',
346
-            //'border_color_hv'   => 'cccccc',
347
-            'border_color'      => 'cccccc',
348
-            'field_border_width' => '1px',
349
-            'field_border_style' => 'solid',
350
-
351
-            'bg_color'          => 'ffffff',
352
-            //'bg_color_hv'       => 'ffffff',
345
+			'text_color'        => '555555',
346
+			//'border_color_hv'   => 'cccccc',
347
+			'border_color'      => 'cccccc',
348
+			'field_border_width' => '1px',
349
+			'field_border_style' => 'solid',
350
+
351
+			'bg_color'          => 'ffffff',
352
+			//'bg_color_hv'       => 'ffffff',
353 353
 			'remove_box_shadow' => '',
354
-            'bg_color_active'   => 'ffffff',
354
+			'bg_color_active'   => 'ffffff',
355 355
 			'border_color_active' => '66afe9',
356 356
 			'remove_box_shadow_active' => '',
357
-            'text_color_error'  => '444444',
358
-            'bg_color_error'    => 'ffffff',
357
+			'text_color_error'  => '444444',
358
+			'bg_color_error'    => 'ffffff',
359 359
 			'border_color_error' => 'B94A48',
360 360
 			'border_width_error' => '1px',
361 361
 			'border_style_error' => 'solid',
362
-            'bg_color_disabled' => 'ffffff',
363
-            'border_color_disabled' => 'E5E5E5',
364
-            'text_color_disabled' => 'A1A1A1',
365
-
366
-            'radio_align'       => 'block',
367
-            'check_align'       => 'block',
368
-            'check_font_size'   => '13px',
369
-            'check_label_color' => '444444',
370
-            'check_weight'      => 'normal',
371
-
372
-            'section_font_size' => '18px',
373
-            'section_color'     => '444444',
374
-            'section_weight'    => 'bold',
375
-            'section_pad'       => '15px 0 3px 0',
376
-            'section_mar_top'   => '15px',
362
+			'bg_color_disabled' => 'ffffff',
363
+			'border_color_disabled' => 'E5E5E5',
364
+			'text_color_disabled' => 'A1A1A1',
365
+
366
+			'radio_align'       => 'block',
367
+			'check_align'       => 'block',
368
+			'check_font_size'   => '13px',
369
+			'check_label_color' => '444444',
370
+			'check_weight'      => 'normal',
371
+
372
+			'section_font_size' => '18px',
373
+			'section_color'     => '444444',
374
+			'section_weight'    => 'bold',
375
+			'section_pad'       => '15px 0 3px 0',
376
+			'section_mar_top'   => '15px',
377 377
 			'section_mar_bottom' => '12px',
378
-            'section_bg_color'  => '',
379
-            'section_border_color' => 'e8e8e8',
380
-            'section_border_width' => '2px',
381
-            'section_border_style' => 'solid',
382
-            'section_border_loc' => '-top',
383
-            'collapse_icon'     => '6',
384
-            'collapse_pos'      => 'after',
385
-            'repeat_icon'       => '1',
386
-
387
-            'submit_style'      => false,
388
-            'submit_font_size'  => '14px',
389
-            'submit_width'      => 'auto',
390
-            'submit_height'     => 'auto',
391
-            'submit_bg_color'   => 'ffffff',
392
-            'submit_border_color' => 'cccccc',
393
-            'submit_border_width' => '1px',
394
-            'submit_text_color' => '444444',
395
-            'submit_weight'     => 'normal',
396
-            'submit_border_radius' => '4px',
397
-            'submit_bg_img'     => '',
398
-            'submit_margin'     => '10px',
399
-            'submit_padding'    => '6px 11px',
400
-            'submit_shadow_color' => 'eeeeee',
401
-            'submit_hover_bg_color' => 'efefef',
402
-            'submit_hover_color' => '444444',
403
-            'submit_hover_border_color' => 'cccccc',
404
-            'submit_active_bg_color' => 'efefef',
405
-            'submit_active_color' => '444444',
406
-            'submit_active_border_color' => 'cccccc',
407
-
408
-            'border_radius'     => '4px',
409
-            'error_bg'          => 'F2DEDE',
410
-            'error_border'      => 'EBCCD1',
411
-            'error_text'        => 'B94A48',
412
-            'error_font_size'   => '14px',
413
-
414
-            'success_bg_color'  => 'DFF0D8',
415
-            'success_border_color' => 'D6E9C6',
416
-            'success_text_color' => '468847',
417
-            'success_font_size' => '14px',
418
-
419
-            'important_style'   => false,
378
+			'section_bg_color'  => '',
379
+			'section_border_color' => 'e8e8e8',
380
+			'section_border_width' => '2px',
381
+			'section_border_style' => 'solid',
382
+			'section_border_loc' => '-top',
383
+			'collapse_icon'     => '6',
384
+			'collapse_pos'      => 'after',
385
+			'repeat_icon'       => '1',
386
+
387
+			'submit_style'      => false,
388
+			'submit_font_size'  => '14px',
389
+			'submit_width'      => 'auto',
390
+			'submit_height'     => 'auto',
391
+			'submit_bg_color'   => 'ffffff',
392
+			'submit_border_color' => 'cccccc',
393
+			'submit_border_width' => '1px',
394
+			'submit_text_color' => '444444',
395
+			'submit_weight'     => 'normal',
396
+			'submit_border_radius' => '4px',
397
+			'submit_bg_img'     => '',
398
+			'submit_margin'     => '10px',
399
+			'submit_padding'    => '6px 11px',
400
+			'submit_shadow_color' => 'eeeeee',
401
+			'submit_hover_bg_color' => 'efefef',
402
+			'submit_hover_color' => '444444',
403
+			'submit_hover_border_color' => 'cccccc',
404
+			'submit_active_bg_color' => 'efefef',
405
+			'submit_active_color' => '444444',
406
+			'submit_active_border_color' => 'cccccc',
407
+
408
+			'border_radius'     => '4px',
409
+			'error_bg'          => 'F2DEDE',
410
+			'error_border'      => 'EBCCD1',
411
+			'error_text'        => 'B94A48',
412
+			'error_font_size'   => '14px',
413
+
414
+			'success_bg_color'  => 'DFF0D8',
415
+			'success_border_color' => 'D6E9C6',
416
+			'success_text_color' => '468847',
417
+			'success_font_size' => '14px',
418
+
419
+			'important_style'   => false,
420 420
 
421 421
 			'progress_bg_color'     => 'dddddd',
422 422
 			'progress_active_color' => 'ffffff',
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 			'progress_border_size'  => '2px',
427 427
 			'progress_size'         => '30px',
428 428
 
429
-            'custom_css'        => '',
430
-        );
431
-    }
429
+			'custom_css'        => '',
430
+		);
431
+	}
432 432
 
433 433
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
434 434
 		return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
Please login to merge, or discard this patch.
css/_single_theme.css.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     color:<?php echo esc_html( $text_color . $important ) ?>;
310 310
 	background-color:<?php echo esc_html( $bg_color . $important ); ?>;
311 311
 <?php if ( ! empty($important) ) {
312
-    echo esc_html( 'background-image:none' . $important . ';' );
312
+	echo esc_html( 'background-image:none' . $important . ';' );
313 313
 }
314 314
 ?>
315 315
     border-color: <?php echo esc_html( $border_color . $important ) ?>;
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
     color: <?php echo esc_html( $submit_active_color . $important ) ?>;
553 553
 }
554 554
 <?php
555
-    }
555
+	}
556 556
 }
557 557
 ?>
558 558
 
@@ -877,11 +877,11 @@  discard block
 block discarded – undo
877 877
 
878 878
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
879 879
 <?php
880
-    // calculate the top position based on field padding
881
-    $top_pad = explode(' ', $field_pad);
882
-    $top_pad = reset($top_pad); // the top padding is listed first
883
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
884
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
880
+	// calculate the top position based on field padding
881
+	$top_pad = explode(' ', $field_pad);
882
+	$top_pad = reset($top_pad); // the top padding is listed first
883
+	$pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
884
+	$top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
885 885
 ?>
886 886
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
887 887
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 $settings = FrmStylesHelper::get_settings_for_output( $style );
4 4
 extract( $settings );
5 5
 
6
-$important = empty($important_style) ? '' : ' !important';
6
+$important = empty( $important_style ) ? '' : ' !important';
7 7
 $label_margin = (int) $width + 10;
8 8
 
9 9
 $minus_icons = FrmStylesHelper::minus_icons();
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 }
112 112
 
113 113
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before{
114
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ) ?>";
114
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['-'] : $minus_icons[1]['-'] ) ?>";
115 115
 }
116 116
 
117 117
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_plus_icon:before{
118
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['+'] : $minus_icons[1]['+'] ) ?>";
118
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['+'] : $minus_icons[1]['+'] ) ?>";
119 119
 }
120 120
 
121 121
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before,
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 }
125 125
 
126 126
 .<?php echo esc_html( $style_class ) ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{
127
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ) ?>";
127
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['-'] : $arrow_icons[1]['-'] ) ?>";
128 128
 	color:<?php echo esc_html( $section_color . $important ) ?>;
129 129
 }
130 130
 
131 131
 .<?php echo esc_html( $style_class ) ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{
132
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ) ?>";
132
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['+'] : $arrow_icons[1]['+'] ) ?>";
133 133
 	color:<?php echo esc_html( $section_color . $important ) ?>;
134 134
 }
135 135
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single{
309 309
     color:<?php echo esc_html( $text_color . $important ) ?>;
310 310
 	background-color:<?php echo esc_html( $bg_color . $important ); ?>;
311
-<?php if ( ! empty($important) ) {
311
+<?php if ( ! empty( $important ) ) {
312 312
     echo esc_html( 'background-image:none' . $important . ';' );
313 313
 }
314 314
 ?>
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
     line-height:normal<?php echo esc_html( $important ) ?>;
497 497
     text-align:center;
498 498
     background: <?php echo esc_html( $submit_bg_color );
499
-	if ( ! empty($submit_bg_img) ) {
499
+	if ( ! empty( $submit_bg_img ) ) {
500 500
 		echo esc_html( ' url(' . $submit_bg_img . ')' );
501 501
 	}
502 502
 	echo esc_html( $important ); ?>;
@@ -878,10 +878,10 @@  discard block
 block discarded – undo
878 878
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
879 879
 <?php
880 880
     // calculate the top position based on field padding
881
-    $top_pad = explode(' ', $field_pad);
882
-    $top_pad = reset($top_pad); // the top padding is listed first
883
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
884
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
881
+    $top_pad = explode( ' ', $field_pad );
882
+    $top_pad = reset( $top_pad ); // the top padding is listed first
883
+    $pad_unit = preg_replace( '/[0-9]+/', '', $top_pad ); //px, em, rem...
884
+    $top_margin = (int) str_replace( $pad_unit, '', $top_pad ) / 2;
885 885
 ?>
886 886
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
887 887
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 			$s_query['it.form_id'] = $form_id;
20 20
 		}
21 21
 
22
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
22
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
23 23
 
24 24
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
25 25
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	    }
28 28
 
29 29
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
30
-        if ( strpos($orderby, 'meta') !== false ) {
30
+        if ( strpos( $orderby, 'meta' ) !== false ) {
31 31
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
32 32
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
33 33
         }
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
40 40
 
41 41
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
42
-        $total_items = FrmEntry::getRecordCount($s_query);
42
+        $total_items = FrmEntry::getRecordCount( $s_query );
43 43
 
44 44
 		$this->set_pagination_args( array(
45 45
 			'total_items' => $total_items,
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 
50 50
 	public function no_items() {
51 51
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
52
-	    if ( ! empty($s) ) {
52
+	    if ( ! empty( $s ) ) {
53 53
             _e( 'No Entries Found', 'formidable' );
54 54
             return;
55 55
         }
56 56
 
57 57
         $form_id = $form = $this->params['form'];
58 58
         if ( $form_id ) {
59
-            $form = FrmForm::getOne($form_id);
59
+            $form = FrmForm::getOne( $form_id );
60 60
         }
61 61
         $colspan = $this->get_column_count();
62 62
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
 		$r = "<tr id='item-action-{$item->id}'$style>";
106 106
 
107
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
107
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
108 108
         $action_col = false;
109 109
 
110 110
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             }
122 122
 
123 123
 			$attributes = 'class="' . esc_attr( $class ) . '"';
124
-			unset($class);
124
+			unset( $class );
125 125
 			$attributes .= ' data-colname="' . $column_display_name . '"';
126 126
 
127 127
 			$col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
@@ -138,24 +138,24 @@  discard block
 block discarded – undo
138 138
 				    break;
139 139
 				case 'name':
140 140
 				case 'description':
141
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
141
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
142 142
 				    break;
143 143
 				case 'created_at':
144 144
 				case 'updated_at':
145
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
145
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
146 146
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
147 147
 					break;
148 148
 				case 'is_draft':
149
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
149
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
150 150
 			        break;
151 151
 				case 'form_id':
152
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
152
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
153 153
     				break;
154 154
 				case 'post_id':
155
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
155
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
156 156
 				    break;
157 157
 				case 'user_id':
158
-				    $user = get_userdata($item->user_id);
158
+				    $user = get_userdata( $item->user_id );
159 159
 				    $val = $user->user_login;
160 160
 				    break;
161 161
 				default:
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 			    }
178 178
 			    $r .= '</td>';
179 179
 			}
180
-			unset($val);
180
+			unset( $val );
181 181
 		}
182 182
 		$r .= '</tr>';
183 183
 
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
     private function get_actions( &$actions, $item, $view_link ) {
191 191
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
192 192
 
193
-        if ( current_user_can('frm_delete_entries') ) {
193
+        if ( current_user_can( 'frm_delete_entries' ) ) {
194 194
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
195 195
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
196 196
 	    }
197 197
 
198
-        $actions = apply_filters('frm_row_actions', $actions, $item);
198
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
199 199
     }
200 200
 
201 201
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $per_page;
9
+		global $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12
-        $form_id = $this->params['form'];
12
+		$form_id = $this->params['form'];
13 13
 
14 14
 		$default_orderby = 'id';
15 15
 		$default_order = 'DESC';
@@ -21,25 +21,25 @@  discard block
 block discarded – undo
21 21
 
22 22
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
23 23
 
24
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
25
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
26
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
27
-	    }
24
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
25
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
26
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
27
+		}
28 28
 
29
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
30
-        if ( strpos($orderby, 'meta') !== false ) {
31
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
29
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
30
+		if ( strpos($orderby, 'meta') !== false ) {
31
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
32 32
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
33
-        }
33
+		}
34 34
 
35 35
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
36 36
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
37 37
 
38
-        $page = $this->get_pagenum();
38
+		$page = $this->get_pagenum();
39 39
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
40 40
 
41 41
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
42
-        $total_items = FrmEntry::getRecordCount($s_query);
42
+		$total_items = FrmEntry::getRecordCount($s_query);
43 43
 
44 44
 		$this->set_pagination_args( array(
45 45
 			'total_items' => $total_items,
@@ -48,19 +48,19 @@  discard block
 block discarded – undo
48 48
 	}
49 49
 
50 50
 	public function no_items() {
51
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
52
-	    if ( ! empty($s) ) {
53
-            _e( 'No Entries Found', 'formidable' );
54
-            return;
55
-        }
51
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
52
+		if ( ! empty($s) ) {
53
+			_e( 'No Entries Found', 'formidable' );
54
+			return;
55
+		}
56 56
 
57 57
 		$form_id = $this->params['form'];
58 58
 		$form = $this->params['form'];
59 59
 
60
-        if ( $form_id ) {
61
-            $form = FrmForm::getOne($form_id);
62
-        }
63
-        $colspan = $this->get_column_count();
60
+		if ( $form_id ) {
61
+			$form = FrmForm::getOne($form_id);
62
+		}
63
+		$colspan = $this->get_column_count();
64 64
 
65 65
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
66 66
 	}
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	/**
83
-	* Gets the name of the primary column in the Entries screen
84
-	*
85
-	* @since 2.0.14
86
-	*
87
-	* @return string $primary_column
88
-	*/
83
+	 * Gets the name of the primary column in the Entries screen
84
+	 *
85
+	 * @since 2.0.14
86
+	 *
87
+	 * @return string $primary_column
88
+	 */
89 89
 	protected function get_primary_column_name() {
90 90
 		$columns = get_column_headers( $this->screen );
91 91
 		$hidden = get_hidden_columns( $this->screen );
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
 		$this->get_actions( $actions, $item, $view_link );
111 111
 
112
-        $action_links = $this->row_actions( $actions );
112
+		$action_links = $this->row_actions( $actions );
113 113
 
114 114
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
115 115
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		$r = "<tr id='item-action-{$item->id}'$style>";
118 118
 
119 119
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
120
-        $action_col = false;
120
+		$action_col = false;
121 121
 
122 122
 		foreach ( $columns as $column_name => $column_display_name ) {
123 123
 			$class = $column_name . ' column-' . $column_name;
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 			if ( in_array( $column_name, $hidden ) ) {
130 130
 				$class .= ' frm_hidden';
131 131
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
132
-			    $action_col = $column_name;
133
-            }
132
+				$action_col = $column_name;
133
+			}
134 134
 
135 135
 			$attributes = 'class="' . esc_attr( $class ) . '"';
136 136
 			unset($class);
@@ -147,30 +147,30 @@  discard block
 block discarded – undo
147 147
 				case 'ip':
148 148
 				case 'id':
149 149
 				case 'item_key':
150
-				    $val = $item->{$col_name};
151
-				    break;
150
+					$val = $item->{$col_name};
151
+					break;
152 152
 				case 'name':
153 153
 				case 'description':
154
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
155
-				    break;
154
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
155
+					break;
156 156
 				case 'created_at':
157 157
 				case 'updated_at':
158
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
158
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
159 159
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
160 160
 					break;
161 161
 				case 'is_draft':
162
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
163
-			        break;
162
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
163
+					break;
164 164
 				case 'form_id':
165
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
166
-    				break;
165
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
166
+					break;
167 167
 				case 'post_id':
168
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
169
-				    break;
168
+					$val = FrmAppHelper::post_edit_link($item->post_id);
169
+					break;
170 170
 				case 'user_id':
171
-				    $user = get_userdata($item->user_id);
172
-				    $val = $user->user_login;
173
-				    break;
171
+					$user = get_userdata($item->user_id);
172
+					$val = $user->user_login;
173
+					break;
174 174
 				default:
175 175
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
176 176
 					if ( $val === false ) {
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 			}
181 181
 
182 182
 			if ( isset( $val ) ) {
183
-			    $r .= "<td $attributes>";
183
+				$r .= "<td $attributes>";
184 184
 				if ( $column_name == $action_col ) {
185 185
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
186 186
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
187
-			        $r .= $action_links;
187
+					$r .= $action_links;
188 188
 				} else {
189
-			        $r .= $val;
190
-			    }
191
-			    $r .= '</td>';
189
+					$r .= $val;
190
+				}
191
+				$r .= '</td>';
192 192
 			}
193 193
 			unset($val);
194 194
 		}
@@ -197,19 +197,19 @@  discard block
 block discarded – undo
197 197
 		return $r;
198 198
 	}
199 199
 
200
-    /**
201
-     * @param string $view_link
202
-     */
203
-    private function get_actions( &$actions, $item, $view_link ) {
200
+	/**
201
+	 * @param string $view_link
202
+	 */
203
+	private function get_actions( &$actions, $item, $view_link ) {
204 204
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
205 205
 
206
-        if ( current_user_can('frm_delete_entries') ) {
206
+		if ( current_user_can('frm_delete_entries') ) {
207 207
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
208 208
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
209
-	    }
209
+		}
210 210
 
211
-        $actions = apply_filters('frm_row_actions', $actions, $item);
212
-    }
211
+		$actions = apply_filters('frm_row_actions', $actions, $item);
212
+	}
213 213
 
214 214
 	private function get_column_value( $item, &$val ) {
215 215
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
classes/models/FrmEntry.php 1 patch
Spacing   +64 added lines, -64 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
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57 57
         if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
58
+            unset( $check_val['name'] );
59 59
         }
60 60
 
61 61
         global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
64
+        if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) {
65 65
             return false;
66 66
         }
67 67
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
             $is_duplicate = true;
71 71
 
72 72
             //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
73
+            $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
74 74
             $field_metas = array();
75 75
             foreach ( $metas as $meta ) {
76
-				$field_metas[ $meta->field_id ] = $meta->meta_value;
76
+				$field_metas[$meta->field_id] = $meta->meta_value;
77 77
             }
78 78
 
79 79
             // If prev entry is empty and current entry is not, they are not duplicates
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
                 return false;
83 83
             }
84 84
 
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
85
+            $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) );
86 86
             foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
87
+                if ( ! empty( $meta_value ) ) {
88 88
                     $is_duplicate = false;
89 89
                     continue;
90 90
                 }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		}
114 114
 
115 115
 		// If CSV is importing, don't check for duplicates
116
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
116
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
117 117
 			return false;
118 118
 		}
119 119
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         $new_values['is_draft'] = $values->is_draft;
137 137
 		$new_values['user_id'] = (int) $values->user_id;
138 138
 		$new_values['updated_by'] = (int) $values->user_id;
139
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
139
+        $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null;
140 140
 		$new_values['created_at'] = current_time( 'mysql', 1 );
141 141
 		$new_values['updated_at'] = $new_values['created_at'];
142 142
 
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
         $entry_id = $wpdb->insert_id;
149 149
 
150 150
         global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
151
+        if ( ! isset( $frm_vars['saved_entries'] ) ) {
152 152
             $frm_vars['saved_entries'] = array();
153 153
         }
154 154
         $frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+        FrmEntryMeta::duplicate_entry_metas( $id, $entry_id );
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$new_values = self::package_entry_to_update( $id, $values );
194 194
 
195
-		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') );
195
+		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) );
196 196
 
197 197
 		self::after_update_entry( $query_results, $id, $values, $new_values );
198 198
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             return $result;
210 210
         }
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+        do_action( 'frm_before_destroy_entry', $id, $entry );
213 213
 
214 214
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215 215
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
 	public static function &update_form( $id, $value, $form_id ) {
223 223
         global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
224
+        $form_id = isset( $value ) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
         $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
271
+        $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
272 272
         $query_args = array( $id );
273 273
         $query = $wpdb->prepare( $query, $query_args );
274 274
 
275 275
         if ( ! $meta ) {
276 276
 			$entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
277
+            return stripslashes_deep( $entry );
278 278
         }
279 279
 
280 280
         $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281 281
         if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
282
+            return stripslashes_deep( $entry );
283 283
         }
284 284
 
285 285
         $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
286
+        $entry = self::get_meta( $entry );
287 287
 
288
-        return stripslashes_deep($entry);
288
+        return stripslashes_deep( $entry );
289 289
     }
290 290
 
291 291
 	public static function get_meta( $entry ) {
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
302 302
         foreach ( $metas as $meta_val ) {
303 303
             if ( $meta_val->item_id == $entry->id ) {
304
-				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
304
+				$entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306
-					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
306
+					$entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id];
307 307
 				}
308 308
                  continue;
309 309
             }
310 310
 
311 311
             // include sub entries in an array
312
-			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313
-				$entry->metas[ $meta_val->field_id ] = array();
312
+			if ( ! isset( $entry_metas[$meta_val->field_id] ) ) {
313
+				$entry->metas[$meta_val->field_id] = array();
314 314
             }
315 315
 
316
-			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
316
+			$entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
318
+            unset( $meta_val );
319 319
         }
320
-        unset($metas);
320
+        unset( $metas );
321 321
 
322 322
 		FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' );
323 323
 
@@ -335,24 +335,24 @@  discard block
 block discarded – undo
335 335
             return $exists;
336 336
         }
337 337
 
338
-        if ( is_numeric($id) ) {
338
+        if ( is_numeric( $id ) ) {
339 339
             $where = array( 'id' => $id );
340 340
         } else {
341 341
             $where = array( 'item_key' => $id );
342 342
         }
343 343
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
345
+        $exists = ( $id && $id > 0 ) ? true : false;
346 346
         return $exists;
347 347
     }
348 348
 
349 349
     public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+        $limit = FrmAppHelper::esc_limit( $limit );
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+        $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
355
+        $entries = wp_cache_get( $cache_key, 'frm_entry' );
356 356
 
357 357
         if ( false === $entries ) {
358 358
             $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
 		    }
372 372
 
373 373
 			// prepare the query
374
-			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
374
+			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+            $entries = $wpdb->get_results( $query, OBJECT_K );
377
+            unset( $query );
378 378
 
379 379
 			FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' );
380 380
         }
381 381
 
382 382
         if ( ! $meta || ! $entries ) {
383
-            return stripslashes_deep($entries);
383
+            return stripslashes_deep( $entries );
384 384
         }
385
-        unset($meta);
385
+        unset( $meta );
386 386
 
387
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
387
+        if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
388 388
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
389 389
         }
390 390
 
391 391
         $meta_where = array( 'field_id !' => 0 );
392
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
392
+        if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
393 393
             $meta_where['fi.form_id'] = $where['it.form_id'];
394 394
         } else {
395 395
             $meta_where['item_id'] = array_keys( $entries );
@@ -400,21 +400,21 @@  discard block
 block discarded – undo
400 400
         unset( $meta_where );
401 401
 
402 402
         if ( ! $metas ) {
403
-            return stripslashes_deep($entries);
403
+            return stripslashes_deep( $entries );
404 404
         }
405 405
 
406 406
         foreach ( $metas as $m_key => $meta_val ) {
407
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
407
+            if ( ! isset( $entries[$meta_val->item_id] ) ) {
408 408
                 continue;
409 409
             }
410 410
 
411
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
412
-				$entries[ $meta_val->item_id ]->metas = array();
411
+            if ( ! isset( $entries[$meta_val->item_id]->metas ) ) {
412
+				$entries[$meta_val->item_id]->metas = array();
413 413
             }
414 414
 
415
-			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
415
+			$entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
416 416
 
417
-            unset($m_key, $meta_val);
417
+            unset( $m_key, $meta_val );
418 418
         }
419 419
 
420 420
 		if ( ! FrmAppHelper::prevent_caching() ) {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 			}
425 425
 		}
426 426
 
427
-        return stripslashes_deep($entries);
427
+        return stripslashes_deep( $entries );
428 428
     }
429 429
 
430 430
     // Pagination Methods
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         global $wpdb;
433 433
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
434 434
 
435
-        if ( is_numeric($where) ) {
435
+        if ( is_numeric( $where ) ) {
436 436
             $table_join = 'frm_items';
437 437
             $where = array( 'form_id' => $where );
438 438
         }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 		self::sanitize_entry_post( $values );
475 475
 
476 476
 		if ( $type != 'xml' ) {
477
-			$values = apply_filters('frm_pre_create_entry', $values);
477
+			$values = apply_filters( 'frm_pre_create_entry', $values );
478 478
 		}
479 479
 
480 480
 		$new_values = self::package_entry_data( $values );
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
 			'user_id' => self::get_entry_user_id( $values ),
555 555
 		);
556 556
 
557
-		if ( is_array($new_values['name']) ) {
558
-			$new_values['name'] = reset($new_values['name']);
557
+		if ( is_array( $new_values['name'] ) ) {
558
+			$new_values['name'] = reset( $new_values['name'] );
559 559
 		}
560 560
 
561
-		$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
561
+		$new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
562 562
 
563 563
 		return $new_values;
564 564
 	}
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 	* @return int
594 594
 	*/
595 595
 	private static function get_post_id( $values ) {
596
-		return isset( $values['post_id'] ) ? (int) $values['post_id']: 0;
596
+		return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0;
597 597
 	}
598 598
 
599 599
 	/**
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 	* @return int
605 605
 	*/
606 606
 	private static function get_parent_item_id( $values ) {
607
-		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0;
607
+		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0;
608 608
 	}
609 609
 
610 610
 	/**
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	* @return string
616 616
 	*/
617 617
 	private static function get_created_at( $values ) {
618
-		return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1);
618
+		return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 );
619 619
 	}
620 620
 
621 621
 	/**
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
704 704
 		global $frm_vars;
705 705
 
706
-		if ( ! isset($frm_vars['saved_entries']) ) {
706
+		if ( ! isset( $frm_vars['saved_entries'] ) ) {
707 707
 			$frm_vars['saved_entries'] = array();
708 708
 		}
709 709
 
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 	* @param int $entry_id
719 719
 	*/
720 720
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
721
-		if ( isset($values['item_meta']) ) {
721
+		if ( isset( $values['item_meta'] ) ) {
722 722
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
723 723
 		}
724 724
 	}
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
736 736
 
737 737
 		do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) );
738
-		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id , compact( 'is_child' ) );
738
+		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) );
739 739
 	}
740 740
 
741 741
 	/**
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		}
777 777
 
778 778
 		if ( $update && $update_type != 'xml' ) {
779
-			$values = apply_filters('frm_pre_update_entry', $values, $id);
779
+			$values = apply_filters( 'frm_pre_update_entry', $values, $id );
780 780
 		}
781 781
 
782 782
 		return $update;
@@ -797,27 +797,27 @@  discard block
 block discarded – undo
797 797
 			'name'      => self::get_new_entry_name( $values ),
798 798
 			'form_id'   => self::get_form_id( $values ),
799 799
 			'is_draft'  => self::get_is_draft_value( $values ),
800
-			'updated_at' => current_time('mysql', 1),
801
-			'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(),
800
+			'updated_at' => current_time( 'mysql', 1 ),
801
+			'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
802 802
 		);
803 803
 
804
-		if ( isset($values['post_id']) ) {
804
+		if ( isset( $values['post_id'] ) ) {
805 805
 			$new_values['post_id'] = (int) $values['post_id'];
806 806
 		}
807 807
 
808
-		if ( isset($values['item_key']) ) {
808
+		if ( isset( $values['item_key'] ) ) {
809 809
 			$new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
810 810
 		}
811 811
 
812
-		if ( isset($values['parent_item_id']) ) {
812
+		if ( isset( $values['parent_item_id'] ) ) {
813 813
 			$new_values['parent_item_id'] = (int) $values['parent_item_id'];
814 814
 		}
815 815
 
816
-		if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) {
816
+		if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
817 817
 			$new_values['user_id'] = $values['frm_user_id'];
818 818
 		}
819 819
 
820
-		$new_values = apply_filters('frm_update_entry', $new_values, $id);
820
+		$new_values = apply_filters( 'frm_update_entry', $new_values, $id );
821 821
 
822 822
 		return $new_values;
823 823
 	}
Please login to merge, or discard this patch.
classes/models/FrmEntryFormat.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			if ( ! self::skip_field( $atts, $f ) ) {
53 53
 				self::fill_entry_values( $atts, $f, $values );
54 54
 			}
55
-			unset($f);
55
+			unset( $f );
56 56
 		}
57 57
 
58 58
 		self::fill_entry_user_info( $atts, $values );
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			'type'  => $f->type,
122 122
 		);
123 123
 
124
-		$values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
124
+		$values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
125 125
 	}
126 126
 
127 127
 	public static function fill_entry_values( $atts, $f, array &$values ) {
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 		self::maybe_strip_html( $atts['plain_text'], $val );
165 165
 
166 166
 		if ( $atts['format'] != 'text' ) {
167
-			$values[ $f->field_key ] = $val;
167
+			$values[$f->field_key] = $val;
168 168
 			if ( $atts['entry'] && $f->type != 'textarea' ) {
169
-				$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
169
+				$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
170 170
 				if ( $prev_val != $val ) {
171
-					$values[ $f->field_key . '-value' ] = $prev_val;
171
+					$values[$f->field_key . '-value'] = $prev_val;
172 172
 				}
173 173
 			}
174 174
 		} else {
175
-			$values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
175
+			$values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
176 176
 		}
177 177
 	}
178 178
 
179 179
 	private static function fill_missing_fields( $atts, &$values ) {
180
-		if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
180
+		if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) {
181 181
 			// In case include_blank is set
182
-			$atts['entry']->metas[ $atts['field']->id ] = '';
182
+			$atts['entry']->metas[$atts['field']->id] = '';
183 183
 			$atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) );
184 184
 			self::fill_values_from_entry( $atts, $values );
185 185
 		}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	private static function get_field_value( $atts, &$val ) {
193 193
 		$f = $atts['field'];
194 194
 		if ( $atts['entry'] ) {
195
-			$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
195
+			$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
196 196
 			$meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type );
197 197
 
198 198
 			//This filter applies to the default-message shortcode and frm-show-entry shortcode only
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 			return;
249 249
 		}
250 250
 
251
-		$data  = self::get_entry_description_data( $atts );
251
+		$data = self::get_entry_description_data( $atts );
252 252
 
253 253
 		if ( $atts['default_email'] ) {
254 254
 			$atts['entry']->ip = '[ip]';
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
336 336
 
337 337
 		// see how many we have
338
-		$i = count($matches['browser']);
338
+		$i = count( $matches['browser'] );
339 339
 		if ( $i != 1 ) {
340 340
 			//we will have two since we are not using 'other' argument yet
341 341
 			//see if version is before or after the name
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 		self::convert_entry_to_content( $values, $atts, $content );
361 361
 
362 362
 		if ( 'text' == $atts['format'] ) {
363
-			$content = implode('', $content);
363
+			$content = implode( '', $content );
364 364
 		}
365 365
 
366 366
 		if ( $atts['clickable'] ) {
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 
414 414
 		// merge defaults, global settings, and shortcode options
415 415
 		foreach ( $default_settings as $key => $setting ) {
416
-			if ( $atts[ $key ] != '' ) {
416
+			if ( $atts[$key] != '' ) {
417 417
 				continue;
418 418
 			}
419 419
 
420
-			$atts[ $key ] = $setting;
420
+			$atts[$key] = $setting;
421 421
 			unset( $key, $setting );
422 422
 		}
423 423
 	}
Please login to merge, or discard this patch.
classes/models/FrmForm.php 2 patches
Indentation   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -1,262 +1,262 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
3
+	die('You are not allowed to call this page directly.');
4 4
 }
5 5
 
6 6
 class FrmForm {
7 7
 
8
-    /**
9
-     * @return int|boolean id on success or false on failure
10
-     */
11
-    public static function create( $values ) {
12
-        global $wpdb;
8
+	/**
9
+	 * @return int|boolean id on success or false on failure
10
+	 */
11
+	public static function create( $values ) {
12
+		global $wpdb;
13 13
 
14
-        $new_values = array(
14
+		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16
-            'name'          => $values['name'],
17
-            'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
16
+			'name'          => $values['name'],
17
+			'description'   => $values['description'],
18
+			'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
+			'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
+			'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
-        );
22
+			'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
+			'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
+			'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
+		);
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
+		$options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
35
+		$new_values['options'] = serialize($options);
36 36
 
37
-        //if(isset($values['id']) && is_numeric($values['id']))
38
-        //    $new_values['id'] = $values['id'];
37
+		//if(isset($values['id']) && is_numeric($values['id']))
38
+		//    $new_values['id'] = $values['id'];
39 39
 
40 40
 		$wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
41 41
 
42
-        $id = $wpdb->insert_id;
42
+		$id = $wpdb->insert_id;
43 43
 
44 44
 		// Clear form caching
45 45
 		self::clear_form_cache();
46 46
 
47
-        return $id;
48
-    }
47
+		return $id;
48
+	}
49 49
 
50
-    /**
51
-     * @return int|boolean ID on success or false on failure
52
-     */
53
-    public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
-        global $wpdb;
50
+	/**
51
+	 * @return int|boolean ID on success or false on failure
52
+	 */
53
+	public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
+		global $wpdb;
55 55
 
56
-        $values = self::getOne( $id, $blog_id );
57
-        if ( ! $values ) {
58
-            return false;
59
-        }
56
+		$values = self::getOne( $id, $blog_id );
57
+		if ( ! $values ) {
58
+			return false;
59
+		}
60 60
 
61
-        $new_key = $copy_keys ? $values->form_key : '';
61
+		$new_key = $copy_keys ? $values->form_key : '';
62 62
 
63
-        $new_values = array(
63
+		$new_values = array(
64 64
 			'form_key'      => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ),
65
-            'name'          => $values->name,
66
-            'description'   => $values->description,
67
-            'status'        => $template ? 'published' : 'draft',
68
-            'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
-            'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
71
-            'is_template'   => $template ? 1 : 0,
72
-        );
73
-
74
-        if ( $blog_id ) {
75
-            $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
78
-            $new_options['copy'] = false;
79
-            $new_values['options'] = $new_options;
80
-        } else {
81
-            $new_values['options'] = $values->options;
82
-        }
83
-
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
86
-        }
65
+			'name'          => $values->name,
66
+			'description'   => $values->description,
67
+			'status'        => $template ? 'published' : 'draft',
68
+			'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
+			'editable'      => $values->editable ? $values->editable : 0,
70
+			'created_at'    => current_time('mysql', 1),
71
+			'is_template'   => $template ? 1 : 0,
72
+		);
73
+
74
+		if ( $blog_id ) {
75
+			$new_values['status'] = 'published';
76
+			$new_options = maybe_unserialize($values->options);
77
+			$new_options['email_to'] = get_option('admin_email');
78
+			$new_options['copy'] = false;
79
+			$new_values['options'] = $new_options;
80
+		} else {
81
+			$new_values['options'] = $values->options;
82
+		}
83
+
84
+		if ( is_array($new_values['options']) ) {
85
+			$new_values['options'] = serialize($new_values['options']);
86
+		}
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89 89
 
90
-        if ( $query_results ) {
90
+		if ( $query_results ) {
91 91
 			// Clear form caching
92 92
 			self::clear_form_cache();
93 93
 
94
-            $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
94
+			$form_id = $wpdb->insert_id;
95
+			FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
96 96
 
97
-            // update form settings after fields are created
97
+			// update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
99
-            return $form_id;
100
-        }
99
+			return $form_id;
100
+		}
101 101
 
102
-        return false;
103
-    }
102
+		return false;
103
+	}
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106 106
 		$new_opts = maybe_unserialize( $values['options'] );
107 107
 		$values['options'] = $new_opts;
108 108
 
109
-        if ( isset($new_opts['success_msg']) ) {
110
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
111
-        }
109
+		if ( isset($new_opts['success_msg']) ) {
110
+			$new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
111
+		}
112 112
 
113
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113
+		$new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
114 114
 
115
-        if ( $new_opts != $values['options'] ) {
116
-            global $wpdb;
115
+		if ( $new_opts != $values['options'] ) {
116
+			global $wpdb;
117 117
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121
-    /**
122
-     * @return int|boolean
123
-     */
124
-    public static function update( $id, $values, $create_link = false ) {
125
-        global $wpdb;
121
+	/**
122
+	 * @return int|boolean
123
+	 */
124
+	public static function update( $id, $values, $create_link = false ) {
125
+		global $wpdb;
126 126
 
127
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
128
-            $values['status'] = 'published';
129
-        }
127
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
128
+			$values['status'] = 'published';
129
+		}
130 130
 
131
-        if ( isset($values['form_key']) ) {
131
+		if ( isset($values['form_key']) ) {
132 132
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133
-        }
133
+		}
134 134
 
135 135
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136 136
 
137
-        $new_values = self::set_update_options( array(), $values);
137
+		$new_values = self::set_update_options( array(), $values);
138 138
 
139
-        foreach ( $values as $value_key => $value ) {
139
+		foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141 141
 				$new_values[ $value_key ] = $value;
142
-            }
143
-        }
142
+			}
143
+		}
144 144
 
145
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
146
-            $new_values['status'] = $values['new_status'];
147
-        }
145
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
146
+			$new_values['status'] = $values['new_status'];
147
+		}
148 148
 
149
-        if ( ! empty( $new_values ) ) {
149
+		if ( ! empty( $new_values ) ) {
150 150
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
151
-            if ( $query_results ) {
151
+			if ( $query_results ) {
152 152
 				self::clear_form_cache();
153
-            }
154
-        } else {
155
-            $query_results = true;
156
-        }
157
-        unset($new_values);
153
+			}
154
+		} else {
155
+			$query_results = true;
156
+		}
157
+		unset($new_values);
158 158
 
159
-        $values = self::update_fields($id, $values);
159
+		$values = self::update_fields($id, $values);
160 160
 
161 161
 		do_action( 'frm_update_form', $id, $values );
162 162
 		do_action( 'frm_update_form_' . $id, $values );
163 163
 
164
-        return $query_results;
165
-    }
164
+		return $query_results;
165
+	}
166 166
 
167
-    /**
168
-     * @return array
169
-     */
167
+	/**
168
+	 * @return array
169
+	 */
170 170
 	public static function set_update_options( $new_values, $values ) {
171
-        if ( ! isset($values['options']) ) {
172
-            return $new_values;
173
-        }
171
+		if ( ! isset($values['options']) ) {
172
+			return $new_values;
173
+		}
174 174
 
175 175
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
176 176
 		FrmFormsHelper::fill_form_options( $options, $values );
177 177
 
178
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
179
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
180
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
181
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
178
+		$options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
179
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
180
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
181
+		$options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
182 182
 
183
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
184
-        $new_values['options'] = serialize($options);
183
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
184
+		$new_values['options'] = serialize($options);
185 185
 
186
-        return $new_values;
187
-    }
186
+		return $new_values;
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * @return array
192
-     */
190
+	/**
191
+	 * @return array
192
+	 */
193 193
 	public static function update_fields( $id, $values ) {
194 194
 
195
-        if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
196
-            return $values;
197
-        }
195
+		if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
196
+			return $values;
197
+		}
198 198
 
199
-        $all_fields = FrmField::get_all_for_form($id);
200
-        if ( empty($all_fields) ) {
201
-            return $values;
202
-        }
199
+		$all_fields = FrmField::get_all_for_form($id);
200
+		if ( empty($all_fields) ) {
201
+			return $values;
202
+		}
203 203
 
204
-        if ( ! isset($values['item_meta']) ) {
205
-            $values['item_meta'] = array();
206
-        }
204
+		if ( ! isset($values['item_meta']) ) {
205
+			$values['item_meta'] = array();
206
+		}
207 207
 
208
-        $field_array = array();
209
-        $existing_keys = array_keys($values['item_meta']);
210
-        foreach ( $all_fields as $fid ) {
211
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
208
+		$field_array = array();
209
+		$existing_keys = array_keys($values['item_meta']);
210
+		foreach ( $all_fields as $fid ) {
211
+			if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
212 212
 				$values['item_meta'][ $fid->id ] = '';
213
-            }
213
+			}
214 214
 			$field_array[ $fid->id ] = $fid;
215
-        }
216
-        unset($all_fields);
215
+		}
216
+		unset($all_fields);
217 217
 
218
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
219 219
 			if ( isset( $field_array[ $field_id ] ) ) {
220 220
 				$field = $field_array[ $field_id ];
221
-            } else {
222
-                $field = FrmField::getOne($field_id);
223
-            }
221
+			} else {
222
+				$field = FrmField::getOne($field_id);
223
+			}
224 224
 
225
-            if ( ! $field ) {
226
-                continue;
227
-            }
225
+			if ( ! $field ) {
226
+				continue;
227
+			}
228 228
 
229 229
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
230 230
 			if ( $is_settings_page ) {
231
-                //updating the settings page
231
+				//updating the settings page
232 232
 				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
233 233
 					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
234
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
234
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
235 235
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
236
-                } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
237
-                    $prev_opts = $field->field_options;
238
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
239
-                    if ( $prev_opts != $field->field_options ) {
236
+				} else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
237
+					$prev_opts = $field->field_options;
238
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
239
+					if ( $prev_opts != $field->field_options ) {
240 240
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
241
-                    }
242
-                    unset($prev_opts);
243
-                }
244
-            }
241
+					}
242
+					unset($prev_opts);
243
+				}
244
+			}
245 245
 
246 246
 			if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) {
247
-                continue;
248
-            }
247
+				continue;
248
+			}
249 249
 
250
-            //updating the form
250
+			//updating the form
251 251
 			$update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true );
252 252
 			unset( $update_options['custom_html'] ); // don't check for POST html
253 253
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
254 254
 
255 255
 			foreach ( $update_options as $opt => $default ) {
256 256
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
257
-            }
257
+			}
258 258
 
259
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259
+			$field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
260 260
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
261 261
 
262 262
 			$new_field = array(
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 
269 269
 			FrmField::update( $field_id, $new_field );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
272
-        }
271
+			FrmField::delete_form_transient($field->form_id);
272
+		}
273 273
 		self::clear_form_cache();
274 274
 
275
-        return $values;
276
-    }
275
+		return $values;
276
+	}
277 277
 
278 278
 	private static function prepare_field_update_values( $field, $values, &$new_field ) {
279 279
 		$field_cols = array(
@@ -286,113 +286,113 @@  discard block
 block discarded – undo
286 286
 		}
287 287
 	}
288 288
 
289
-    /**
290
-     * @param string $status
291
-     * @return int|boolean
292
-     */
289
+	/**
290
+	 * @param string $status
291
+	 * @return int|boolean
292
+	 */
293 293
 	public static function set_status( $id, $status ) {
294
-        if ( 'trash' == $status ) {
295
-            return self::trash($id);
296
-        }
294
+		if ( 'trash' == $status ) {
295
+			return self::trash($id);
296
+		}
297 297
 
298 298
 		$statuses  = array( 'published', 'draft', 'trash' );
299
-        if ( ! in_array( $status, $statuses ) ) {
300
-            return false;
301
-        }
299
+		if ( ! in_array( $status, $statuses ) ) {
300
+			return false;
301
+		}
302 302
 
303
-        global $wpdb;
303
+		global $wpdb;
304 304
 
305
-        if ( is_array($id) ) {
305
+		if ( is_array($id) ) {
306 306
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
307 307
 			FrmDb::get_where_clause_and_values( $where );
308 308
 			array_unshift( $where['values'], $status );
309 309
 
310 310
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) );
311
-        } else {
311
+		} else {
312 312
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
313 313
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
314
-        }
314
+		}
315 315
 
316
-        if ( $query_results ) {
316
+		if ( $query_results ) {
317 317
 			self::clear_form_cache();
318
-        }
318
+		}
319 319
 
320
-        return $query_results;
321
-    }
320
+		return $query_results;
321
+	}
322 322
 
323
-    /**
324
-     * @return int|boolean
325
-     */
323
+	/**
324
+	 * @return int|boolean
325
+	 */
326 326
 	public static function trash( $id ) {
327
-        if ( ! EMPTY_TRASH_DAYS ) {
328
-            return self::destroy( $id );
329
-        }
327
+		if ( ! EMPTY_TRASH_DAYS ) {
328
+			return self::destroy( $id );
329
+		}
330 330
 
331
-        $form = self::getOne($id);
332
-        if ( ! $form ) {
333
-            return false;
334
-        }
331
+		$form = self::getOne($id);
332
+		if ( ! $form ) {
333
+			return false;
334
+		}
335 335
 
336
-        $options = $form->options;
337
-        $options['trash_time'] = time();
336
+		$options = $form->options;
337
+		$options['trash_time'] = time();
338 338
 
339
-        global $wpdb;
340
-        $query_results = $wpdb->update(
339
+		global $wpdb;
340
+		$query_results = $wpdb->update(
341 341
 			$wpdb->prefix . 'frm_forms',
342 342
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
343 343
 			array( 'id' => $id )
344
-        );
344
+		);
345 345
 
346
-        $wpdb->update(
346
+		$wpdb->update(
347 347
 			$wpdb->prefix . 'frm_forms',
348 348
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
349 349
 			array( 'parent_form_id' => $id )
350
-        );
350
+		);
351 351
 
352
-        if ( $query_results ) {
352
+		if ( $query_results ) {
353 353
 			self::clear_form_cache();
354
-        }
354
+		}
355 355
 
356
-        return $query_results;
357
-    }
356
+		return $query_results;
357
+	}
358 358
 
359
-    /**
360
-     * @return int|boolean
361
-     */
359
+	/**
360
+	 * @return int|boolean
361
+	 */
362 362
 	public static function destroy( $id ) {
363
-        global $wpdb;
363
+		global $wpdb;
364 364
 
365
-        $form = self::getOne($id);
366
-        if ( ! $form ) {
367
-            return false;
368
-        }
365
+		$form = self::getOne($id);
366
+		if ( ! $form ) {
367
+			return false;
368
+		}
369 369
 		$id = $form->id;
370 370
 
371
-        // Disconnect the entries from this form
371
+		// Disconnect the entries from this form
372 372
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
373
-        foreach ( $entries as $entry_id ) {
374
-            FrmEntry::destroy($entry_id);
375
-            unset($entry_id);
376
-        }
373
+		foreach ( $entries as $entry_id ) {
374
+			FrmEntry::destroy($entry_id);
375
+			unset($entry_id);
376
+		}
377 377
 
378
-        // Disconnect the fields from this form
378
+		// Disconnect the fields from this form
379 379
 		$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
380 380
 
381 381
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
382
-        if ( $query_results ) {
383
-            // Delete all form actions linked to this form
384
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
385
-            $action_control->destroy($id, 'all');
382
+		if ( $query_results ) {
383
+			// Delete all form actions linked to this form
384
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
385
+			$action_control->destroy($id, 'all');
386 386
 
387 387
 			// Clear form caching
388 388
 			self::clear_form_cache();
389 389
 
390 390
 			do_action( 'frm_destroy_form', $id );
391 391
 			do_action( 'frm_destroy_form_' . $id );
392
-        }
392
+		}
393 393
 
394
-        return $query_results;
395
-    }
394
+		return $query_results;
395
+	}
396 396
 
397 397
 	/**
398 398
 	 * Delete trashed forms based on how long they have been trashed
@@ -424,49 +424,49 @@  discard block
 block discarded – undo
424 424
 		return $count;
425 425
 	}
426 426
 
427
-    /**
428
-     * @return string form name
429
-     */
430
-    public static function &getName( $id ) {
431
-        global $wpdb;
432
-
433
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
434
-        if ( $form ) {
435
-            $r = stripslashes($form->name);
436
-            return $r;
437
-        }
438
-
439
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
440
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
441
-        $r = stripslashes($r);
442
-
443
-        return $r;
444
-    }
445
-
446
-    /**
447
-     * @param string $key
448
-     * @return int form id
449
-     */
427
+	/**
428
+	 * @return string form name
429
+	 */
430
+	public static function &getName( $id ) {
431
+		global $wpdb;
432
+
433
+		$form = FrmAppHelper::check_cache($id, 'frm_form');
434
+		if ( $form ) {
435
+			$r = stripslashes($form->name);
436
+			return $r;
437
+		}
438
+
439
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
440
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
441
+		$r = stripslashes($r);
442
+
443
+		return $r;
444
+	}
445
+
446
+	/**
447
+	 * @param string $key
448
+	 * @return int form id
449
+	 */
450 450
 	public static function &getIdByKey( $key ) {
451
-        $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
452
-        return $id;
453
-    }
454
-
455
-    /**
456
-     * @param int $id
457
-     * @return string form key
458
-     */
451
+		$id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
452
+		return $id;
453
+	}
454
+
455
+	/**
456
+	 * @param int $id
457
+	 * @return string form key
458
+	 */
459 459
 	public static function &getKeyById( $id ) {
460
-        $id = (int) $id;
461
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
462
-        if ( $cache ) {
463
-            return $cache->form_key;
464
-        }
460
+		$id = (int) $id;
461
+		$cache = FrmAppHelper::check_cache($id, 'frm_form');
462
+		if ( $cache ) {
463
+			return $cache->form_key;
464
+		}
465 465
 
466
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
466
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
467 467
 
468
-        return $key;
469
-    }
468
+		return $key;
469
+	}
470 470
 
471 471
 	/**
472 472
 	 * If $form is numeric, get the form object
@@ -479,47 +479,47 @@  discard block
 block discarded – undo
479 479
 		}
480 480
 	}
481 481
 
482
-    /**
483
-     * @return object form
484
-     */
485
-    public static function getOne( $id, $blog_id = false ) {
486
-        global $wpdb;
482
+	/**
483
+	 * @return object form
484
+	 */
485
+	public static function getOne( $id, $blog_id = false ) {
486
+		global $wpdb;
487 487
 
488
-        if ( $blog_id && is_multisite() ) {
489
-            global $wpmuBaseTablePrefix;
488
+		if ( $blog_id && is_multisite() ) {
489
+			global $wpmuBaseTablePrefix;
490 490
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
491 491
 
492 492
 			$table_name = $prefix . 'frm_forms';
493
-        } else {
493
+		} else {
494 494
 			$table_name = $wpdb->prefix . 'frm_forms';
495
-            $cache = wp_cache_get($id, 'frm_form');
496
-            if ( $cache ) {
497
-                if ( isset($cache->options) ) {
498
-                    $cache->options = maybe_unserialize($cache->options);
499
-                }
495
+			$cache = wp_cache_get($id, 'frm_form');
496
+			if ( $cache ) {
497
+				if ( isset($cache->options) ) {
498
+					$cache->options = maybe_unserialize($cache->options);
499
+				}
500 500
 
501
-                return stripslashes_deep($cache);
502
-            }
503
-        }
501
+				return stripslashes_deep($cache);
502
+			}
503
+		}
504 504
 
505
-        if ( is_numeric($id) ) {
506
-            $where = array( 'id' => $id );
507
-        } else {
508
-            $where = array( 'form_key' => $id );
509
-        }
505
+		if ( is_numeric($id) ) {
506
+			$where = array( 'id' => $id );
507
+		} else {
508
+			$where = array( 'form_key' => $id );
509
+		}
510 510
 
511
-        $results = FrmDb::get_row( $table_name, $where );
511
+		$results = FrmDb::get_row( $table_name, $where );
512 512
 
513
-        if ( isset($results->options) ) {
513
+		if ( isset($results->options) ) {
514 514
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
515
-            $results->options = maybe_unserialize($results->options);
516
-        }
517
-        return stripslashes_deep($results);
518
-    }
519
-
520
-    /**
521
-     * @return object|array of objects
522
-     */
515
+			$results->options = maybe_unserialize($results->options);
516
+		}
517
+		return stripslashes_deep($results);
518
+	}
519
+
520
+	/**
521
+	 * @return object|array of objects
522
+	 */
523 523
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
524 524
 		if ( is_array( $where ) && ! empty( $where ) ) {
525 525
 			$results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) );
@@ -543,8 +543,8 @@  discard block
 block discarded – undo
543 543
 			$results = reset( $results );
544 544
 		}
545 545
 
546
-        return stripslashes_deep($results);
547
-    }
546
+		return stripslashes_deep($results);
547
+	}
548 548
 
549 549
 	/**
550 550
 	 * Get all published forms
@@ -562,47 +562,47 @@  discard block
 block discarded – undo
562 562
 		return $forms;
563 563
 	}
564 564
 
565
-    /**
566
-     * @return int count of forms
567
-     */
568
-    public static function &get_count() {
569
-    	global $wpdb;
565
+	/**
566
+	 * @return int count of forms
567
+	 */
568
+	public static function &get_count() {
569
+		global $wpdb;
570 570
 
571
-    	$cache_key = 'frm_form_counts';
571
+		$cache_key = 'frm_form_counts';
572 572
 
573
-    	$counts = wp_cache_get( $cache_key, 'frm_form' );
574
-    	if ( false !== $counts ) {
575
-    	    return $counts;
576
-    	}
573
+		$counts = wp_cache_get( $cache_key, 'frm_form' );
574
+		if ( false !== $counts ) {
575
+			return $counts;
576
+		}
577 577
 
578
-        $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
578
+		$results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
579 579
 
580 580
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
581
-    	$counts = array_fill_keys( $statuses, 0 );
581
+		$counts = array_fill_keys( $statuses, 0 );
582 582
 
583
-    	foreach ( $results as $row ) {
584
-            if ( 'trash' != $row->status ) {
585
-    	        if ( $row->is_template ) {
583
+		foreach ( $results as $row ) {
584
+			if ( 'trash' != $row->status ) {
585
+				if ( $row->is_template ) {
586 586
 					$counts['template']++;
587
-    	        } else {
587
+				} else {
588 588
 					$counts['published']++;
589
-    	        }
590
-    	    } else {
589
+				}
590
+			} else {
591 591
 				$counts['trash']++;
592
-        	}
592
+			}
593 593
 
594
-    	    if ( 'draft' == $row->status ) {
594
+			if ( 'draft' == $row->status ) {
595 595
 				$counts['draft']++;
596
-    	    }
596
+			}
597 597
 
598
-    		unset($row);
599
-    	}
598
+			unset($row);
599
+		}
600 600
 
601
-    	$counts = (object) $counts;
601
+		$counts = (object) $counts;
602 602
 		FrmAppHelper::set_cache( $cache_key, $counts, 'frm_form' );
603 603
 
604
-    	return $counts;
605
-    }
604
+		return $counts;
605
+	}
606 606
 
607 607
 	/**
608 608
 	 * Clear form caching
@@ -615,14 +615,14 @@  discard block
 block discarded – undo
615 615
 		FrmAppHelper::cache_delete_group( 'frm_form' );
616 616
 	}
617 617
 
618
-    /**
619
-     * @return array of errors
620
-     */
618
+	/**
619
+	 * @return array of errors
620
+	 */
621 621
 	public static function validate( $values ) {
622
-        $errors = array();
622
+		$errors = array();
623 623
 
624
-        return apply_filters('frm_validate_form', $errors, $values);
625
-    }
624
+		return apply_filters('frm_validate_form', $errors, $values);
625
+	}
626 626
 
627 627
 	public static function get_params( $form = null ) {
628 628
 		global $frm_vars;
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16 16
             'name'          => $values['name'],
17 17
             'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
18
+            'status'        => isset( $values['status'] ) ? $values['status'] : 'draft',
19
+            'logged_in'     => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
20
+            'is_template'   => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
22
+            'editable'      => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
23
+            'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
24
+            'created_at'    => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
25 25
         );
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
31
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
32
+        $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
35
+        $new_values['options'] = serialize( $options );
36 36
 
37 37
         //if(isset($values['id']) && is_numeric($values['id']))
38 38
         //    $new_values['id'] = $values['id'];
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
             'status'        => $template ? 'published' : 'draft',
68 68
             'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69 69
             'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
70
+            'created_at'    => current_time( 'mysql', 1 ),
71 71
             'is_template'   => $template ? 1 : 0,
72 72
         );
73 73
 
74 74
         if ( $blog_id ) {
75 75
             $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
76
+            $new_options = maybe_unserialize( $values->options );
77
+            $new_options['email_to'] = get_option( 'admin_email' );
78 78
             $new_options['copy'] = false;
79 79
             $new_values['options'] = $new_options;
80 80
         } else {
81 81
             $new_values['options'] = $values->options;
82 82
         }
83 83
 
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
84
+        if ( is_array( $new_values['options'] ) ) {
85
+            $new_values['options'] = serialize( $new_values['options'] );
86 86
         }
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			self::clear_form_cache();
93 93
 
94 94
             $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
95
+            FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97 97
             // update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		$new_opts = maybe_unserialize( $values['options'] );
107 107
 		$values['options'] = $new_opts;
108 108
 
109
-        if ( isset($new_opts['success_msg']) ) {
110
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
109
+        if ( isset( $new_opts['success_msg'] ) ) {
110
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
111 111
         }
112 112
 
113
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
114 114
 
115 115
         if ( $new_opts != $values['options'] ) {
116 116
             global $wpdb;
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
             $values['status'] = 'published';
129 129
         }
130 130
 
131
-        if ( isset($values['form_key']) ) {
131
+        if ( isset( $values['form_key'] ) ) {
132 132
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133 133
         }
134 134
 
135 135
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136 136
 
137
-        $new_values = self::set_update_options( array(), $values);
137
+        $new_values = self::set_update_options( array(), $values );
138 138
 
139 139
         foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141
-				$new_values[ $value_key ] = $value;
141
+				$new_values[$value_key] = $value;
142 142
             }
143 143
         }
144 144
 
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
         } else {
155 155
             $query_results = true;
156 156
         }
157
-        unset($new_values);
157
+        unset( $new_values );
158 158
 
159
-        $values = self::update_fields($id, $values);
159
+        $values = self::update_fields( $id, $values );
160 160
 
161 161
 		do_action( 'frm_update_form', $id, $values );
162 162
 		do_action( 'frm_update_form_' . $id, $values );
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
      * @return array
169 169
      */
170 170
 	public static function set_update_options( $new_values, $values ) {
171
-        if ( ! isset($values['options']) ) {
171
+        if ( ! isset( $values['options'] ) ) {
172 172
             return $new_values;
173 173
         }
174 174
 
175 175
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
176 176
 		FrmFormsHelper::fill_form_options( $options, $values );
177 177
 
178
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
179
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
180
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
181
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
178
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
179
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
180
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
181
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
182 182
 
183
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
184
-        $new_values['options'] = serialize($options);
183
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
184
+        $new_values['options'] = serialize( $options );
185 185
 
186 186
         return $new_values;
187 187
     }
@@ -192,54 +192,54 @@  discard block
 block discarded – undo
192 192
      */
193 193
 	public static function update_fields( $id, $values ) {
194 194
 
195
-        if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
+        if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
196 196
             return $values;
197 197
         }
198 198
 
199
-        $all_fields = FrmField::get_all_for_form($id);
200
-        if ( empty($all_fields) ) {
199
+        $all_fields = FrmField::get_all_for_form( $id );
200
+        if ( empty( $all_fields ) ) {
201 201
             return $values;
202 202
         }
203 203
 
204
-        if ( ! isset($values['item_meta']) ) {
204
+        if ( ! isset( $values['item_meta'] ) ) {
205 205
             $values['item_meta'] = array();
206 206
         }
207 207
 
208 208
         $field_array = array();
209
-        $existing_keys = array_keys($values['item_meta']);
209
+        $existing_keys = array_keys( $values['item_meta'] );
210 210
         foreach ( $all_fields as $fid ) {
211
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
212
-				$values['item_meta'][ $fid->id ] = '';
211
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
212
+				$values['item_meta'][$fid->id] = '';
213 213
             }
214
-			$field_array[ $fid->id ] = $fid;
214
+			$field_array[$fid->id] = $fid;
215 215
         }
216
-        unset($all_fields);
216
+        unset( $all_fields );
217 217
 
218 218
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
219
-			if ( isset( $field_array[ $field_id ] ) ) {
220
-				$field = $field_array[ $field_id ];
219
+			if ( isset( $field_array[$field_id] ) ) {
220
+				$field = $field_array[$field_id];
221 221
             } else {
222
-                $field = FrmField::getOne($field_id);
222
+                $field = FrmField::getOne( $field_id );
223 223
             }
224 224
 
225 225
             if ( ! $field ) {
226 226
                 continue;
227 227
             }
228 228
 
229
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
230 230
 			if ( $is_settings_page ) {
231 231
                 //updating the settings page
232
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
233
-					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
234
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
232
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
233
+					$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
234
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
235 235
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
236 236
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
237 237
                     $prev_opts = $field->field_options;
238
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
239 239
                     if ( $prev_opts != $field->field_options ) {
240 240
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
241 241
                     }
242
-                    unset($prev_opts);
242
+                    unset( $prev_opts );
243 243
                 }
244 244
             }
245 245
 
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
254 254
 
255 255
 			foreach ( $update_options as $opt => $default ) {
256
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
256
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
257 257
             }
258 258
 
259
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
260
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
259
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
260
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
261 261
 
262 262
 			$new_field = array(
263 263
 				'field_options' => $field->field_options,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
 			FrmField::update( $field_id, $new_field );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
271
+            FrmField::delete_form_transient( $field->form_id );
272 272
         }
273 273
 		self::clear_form_cache();
274 274
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		);
283 283
 		foreach ( $field_cols as $col => $default ) {
284 284
 			$default = ( $default === '' ) ? $field->{$col} : $default;
285
-			$new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
285
+			$new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default;
286 286
 		}
287 287
 	}
288 288
 
@@ -292,17 +292,17 @@  discard block
 block discarded – undo
292 292
      */
293 293
 	public static function set_status( $id, $status ) {
294 294
         if ( 'trash' == $status ) {
295
-            return self::trash($id);
295
+            return self::trash( $id );
296 296
         }
297 297
 
298
-		$statuses  = array( 'published', 'draft', 'trash' );
298
+		$statuses = array( 'published', 'draft', 'trash' );
299 299
         if ( ! in_array( $status, $statuses ) ) {
300 300
             return false;
301 301
         }
302 302
 
303 303
         global $wpdb;
304 304
 
305
-        if ( is_array($id) ) {
305
+        if ( is_array( $id ) ) {
306 306
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
307 307
 			FrmDb::get_where_clause_and_values( $where );
308 308
 			array_unshift( $where['values'], $status );
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             return self::destroy( $id );
329 329
         }
330 330
 
331
-        $form = self::getOne($id);
331
+        $form = self::getOne( $id );
332 332
         if ( ! $form ) {
333 333
             return false;
334 334
         }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	public static function destroy( $id ) {
363 363
         global $wpdb;
364 364
 
365
-        $form = self::getOne($id);
365
+        $form = self::getOne( $id );
366 366
         if ( ! $form ) {
367 367
             return false;
368 368
         }
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
         // Disconnect the entries from this form
372 372
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
373 373
         foreach ( $entries as $entry_id ) {
374
-            FrmEntry::destroy($entry_id);
375
-            unset($entry_id);
374
+            FrmEntry::destroy( $entry_id );
375
+            unset( $entry_id );
376 376
         }
377 377
 
378 378
         // Disconnect the fields from this form
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         if ( $query_results ) {
383 383
             // Delete all form actions linked to this form
384 384
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
385
-            $action_control->destroy($id, 'all');
385
+            $action_control->destroy( $id, 'all' );
386 386
 
387 387
 			// Clear form caching
388 388
 			self::clear_form_cache();
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 			$form->options = maybe_unserialize( $form->options );
417 417
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
418 418
 				self::destroy( $form->id );
419
-				$count++;
419
+				$count ++;
420 420
 			}
421 421
 
422 422
 			unset( $form );
@@ -430,15 +430,15 @@  discard block
 block discarded – undo
430 430
     public static function &getName( $id ) {
431 431
         global $wpdb;
432 432
 
433
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
433
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
434 434
         if ( $form ) {
435
-            $r = stripslashes($form->name);
435
+            $r = stripslashes( $form->name );
436 436
             return $r;
437 437
         }
438 438
 
439 439
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
440 440
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
441
-        $r = stripslashes($r);
441
+        $r = stripslashes( $r );
442 442
 
443 443
         return $r;
444 444
     }
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
      */
459 459
 	public static function &getKeyById( $id ) {
460 460
         $id = (int) $id;
461
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
461
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
462 462
         if ( $cache ) {
463 463
             return $cache->form_key;
464 464
         }
@@ -492,17 +492,17 @@  discard block
 block discarded – undo
492 492
 			$table_name = $prefix . 'frm_forms';
493 493
         } else {
494 494
 			$table_name = $wpdb->prefix . 'frm_forms';
495
-            $cache = wp_cache_get($id, 'frm_form');
495
+            $cache = wp_cache_get( $id, 'frm_form' );
496 496
             if ( $cache ) {
497
-                if ( isset($cache->options) ) {
498
-                    $cache->options = maybe_unserialize($cache->options);
497
+                if ( isset( $cache->options ) ) {
498
+                    $cache->options = maybe_unserialize( $cache->options );
499 499
                 }
500 500
 
501
-                return stripslashes_deep($cache);
501
+                return stripslashes_deep( $cache );
502 502
             }
503 503
         }
504 504
 
505
-        if ( is_numeric($id) ) {
505
+        if ( is_numeric( $id ) ) {
506 506
             $where = array( 'id' => $id );
507 507
         } else {
508 508
             $where = array( 'form_key' => $id );
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 
511 511
         $results = FrmDb::get_row( $table_name, $where );
512 512
 
513
-        if ( isset($results->options) ) {
513
+        if ( isset( $results->options ) ) {
514 514
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
515
-            $results->options = maybe_unserialize($results->options);
515
+            $results->options = maybe_unserialize( $results->options );
516 516
         }
517
-        return stripslashes_deep($results);
517
+        return stripslashes_deep( $results );
518 518
     }
519 519
 
520 520
     /**
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 			$results = reset( $results );
544 544
 		}
545 545
 
546
-        return stripslashes_deep($results);
546
+        return stripslashes_deep( $results );
547 547
     }
548 548
 
549 549
 	/**
@@ -583,19 +583,19 @@  discard block
 block discarded – undo
583 583
     	foreach ( $results as $row ) {
584 584
             if ( 'trash' != $row->status ) {
585 585
     	        if ( $row->is_template ) {
586
-					$counts['template']++;
586
+					$counts['template'] ++;
587 587
     	        } else {
588
-					$counts['published']++;
588
+					$counts['published'] ++;
589 589
     	        }
590 590
     	    } else {
591
-				$counts['trash']++;
591
+				$counts['trash'] ++;
592 592
         	}
593 593
 
594 594
     	    if ( 'draft' == $row->status ) {
595
-				$counts['draft']++;
595
+				$counts['draft'] ++;
596 596
     	    }
597 597
 
598
-    		unset($row);
598
+    		unset( $row );
599 599
     	}
600 600
 
601 601
     	$counts = (object) $counts;
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	public static function validate( $values ) {
622 622
         $errors = array();
623 623
 
624
-        return apply_filters('frm_validate_form', $errors, $values);
624
+        return apply_filters( 'frm_validate_form', $errors, $values );
625 625
     }
626 626
 
627 627
 	public static function get_params( $form = null ) {
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
 			self::maybe_get_form( $form );
634 634
 		}
635 635
 
636
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
637
-			return $frm_vars['form_params'][ $form->id ];
636
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
637
+			return $frm_vars['form_params'][$form->id];
638 638
 		}
639 639
 
640
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
640
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
641 641
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
642 642
 
643 643
 		$default_values = array(
@@ -655,15 +655,15 @@  discard block
 block discarded – undo
655 655
 			//if there are two forms on the same page, make sure not to submit both
656 656
 			foreach ( $default_values as $var => $default ) {
657 657
 				if ( $var == 'action' ) {
658
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
658
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
659 659
 				} else {
660
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default );
660
+					$values[$var] = FrmAppHelper::get_param( $var, $default );
661 661
 				}
662 662
 				unset( $var, $default );
663 663
 			}
664 664
 		} else {
665 665
 			foreach ( $default_values as $var => $default ) {
666
-				$values[ $var ] = $default;
666
+				$values[$var] = $default;
667 667
 				unset( $var, $default );
668 668
 			}
669 669
 		}
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 	public static function list_page_params() {
679 679
 		$values = array();
680 680
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
681
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
681
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
682 682
 		}
683 683
 
684 684
 		return $values;
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
699 699
 			'keep_post' => '',
700 700
 		) as $var => $default ) {
701
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
701
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
702 702
 		}
703 703
 
704 704
 		return $values;
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 		$small_form = new stdClass();
756 756
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
757 757
 			$small_form->{$var} = $form->{$var};
758
-			unset($var);
758
+			unset( $var );
759 759
 		}
760 760
 
761 761
 		$frm_vars['forms_loaded'][] = $small_form;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 			$frm_vars['load_css'] = true;
766 766
 		}
767 767
 
768
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
768
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
769 769
 	}
770 770
 
771 771
 	public static function show_submit( $form ) {
@@ -779,6 +779,6 @@  discard block
 block discarded – undo
779 779
 	 */
780 780
 	public static function get_option( $atts ) {
781 781
 		$form = $atts['form'];
782
-		return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default'];
782
+		return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default'];
783 783
 	}
784 784
 }
Please login to merge, or discard this patch.
classes/views/frm-entries/form.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( empty($values) || ! isset($values['fields']) || empty($values['fields']) ) { ?>
3
-<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($form); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container">
2
+if ( empty( $values ) || ! isset( $values['fields'] ) || empty( $values['fields'] ) ) { ?>
3
+<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $form ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container">
4 4
 	<div class="frm_error_style"><strong><?php _e( 'Oops!', 'formidable' ) ?></strong> <?php printf( __( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), '<a href="' . esc_url( admin_url( '?page=formidable&frm_action=edit&id=' . $form->id ) ) . '">', '</a>' ) ?>
5 5
     </div>
6 6
 </div>
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>">
19 19
 <fieldset>
20 20
 <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?>
21
-<?php do_action( 'frm_after_title', compact('form') ) ?>
22
-<input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" />
23
-<input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" />
24
-<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr($frm_hide_fields) ?>" />
25
-<input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" />
21
+<?php do_action( 'frm_after_title', compact( 'form' ) ) ?>
22
+<input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ) ?>" />
23
+<input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ) ?>" />
24
+<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr( $frm_hide_fields ) ?>" />
25
+<input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ) ?>" />
26 26
 <input type="hidden" name="item_meta[0]" value="" />
27 27
 <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?>
28 28
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		} else {
36 36
 			do_action( 'frm_show_other_field_type', $field, $form, array( 'action' => $form_action ) );
37 37
 		}
38
-    	do_action('frm_get_field_scripts', $field, $form, $form->id);
38
+    	do_action( 'frm_get_field_scripts', $field, $form, $form->id );
39 39
 	}
40 40
 }
41 41
 
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 if ( FrmAppHelper::is_admin() ) { ?>
44 44
 <div class="frm_form_field form-field">
45 45
 <label class="frm_primary_label"><?php _e( 'Entry Key', 'formidable' ) ?></label>
46
-<input type="text" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" />
46
+<input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" />
47 47
 </div>
48 48
 <?php } else { ?>
49
-<input type="hidden" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" />
49
+<input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" />
50 50
 <?php }
51 51
 
52
-do_action('frm_entry_form', $form, $form_action, $errors);
52
+do_action( 'frm_entry_form', $form, $form_action, $errors );
53 53
 
54 54
 global $frm_vars;
55 55
 // close open section div
@@ -59,22 +59,22 @@  discard block
 block discarded – undo
59 59
 }
60 60
 
61 61
 // close open collapsible toggle div
62
-if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) {
62
+if ( isset( $frm_vars['collapse_div'] ) && $frm_vars['collapse_div'] ) {
63 63
     echo "</div>\n";
64
-    unset($frm_vars['collapse_div']);
64
+    unset( $frm_vars['collapse_div'] );
65 65
 }
66 66
 
67
-echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form);
67
+echo FrmFormsHelper::replace_shortcodes( $values['after_html'], $form );
68 68
 
69 69
 if ( FrmForm::show_submit( $form ) ) {
70
-    unset($values['fields']);
71
-    FrmFormsHelper::get_custom_submit($values['submit_html'], $form, $submit, $form_action, $values);
70
+    unset( $values['fields'] );
71
+    FrmFormsHelper::get_custom_submit( $values['submit_html'], $form, $submit, $form_action, $values );
72 72
 }
73 73
 ?>
74 74
 </fieldset>
75 75
 </div>
76 76
 <?php
77
-if ( has_action('frm_entries_footer_scripts') ) {
77
+if ( has_action( 'frm_entries_footer_scripts' ) ) {
78 78
 ?><script type="text/javascript"><?php
79 79
 do_action( 'frm_entries_footer_scripts', $values['fields'], $form );
80 80
 ?></script><?php
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 1 patch
Spacing   +205 added lines, -205 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
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public static function plugin_folder() {
26
-        return basename(self::plugin_path());
26
+        return basename( self::plugin_path() );
27 27
     }
28 28
 
29 29
     public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
30
+        return dirname( dirname( dirname( __FILE__ ) ) );
31 31
     }
32 32
 
33 33
     public static function plugin_url() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string
55 55
      */
56 56
     public static function site_name() {
57
-        return get_option('blogname');
57
+        return get_option( 'blogname' );
58 58
     }
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 	public static function get_affiliate() {
69 69
 		return '';
70
-		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') );
70
+		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) );
71 71
 		$affiliate_id = strtolower( $affiliate_id );
72 72
 		$allowed_affiliates = array();
73 73
 		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function get_settings() {
88 88
         global $frm_settings;
89
-        if ( empty($frm_settings) ) {
89
+        if ( empty( $frm_settings ) ) {
90 90
             $frm_settings = new FrmSettings();
91 91
         }
92 92
         return $frm_settings;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     }
108 108
 
109 109
     public static function pro_is_installed() {
110
-        return apply_filters('frm_pro_installed', false);
110
+        return apply_filters( 'frm_pro_installed', false );
111 111
     }
112 112
 
113 113
     /**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @return boolean
152 152
      */
153 153
     public static function doing_ajax() {
154
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
154
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
155 155
     }
156 156
 
157 157
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @return boolean
172 172
      */
173 173
     public static function is_admin() {
174
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
174
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
175 175
     }
176 176
 
177 177
     /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      * @return string
199 199
      */
200 200
 	public static function get_server_value( $value ) {
201
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
201
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
202 202
     }
203 203
 
204 204
     /**
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214 214
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215 215
         ) as $key ) {
216
-            if ( ! isset( $_SERVER[ $key ] ) ) {
216
+            if ( ! isset( $_SERVER[$key] ) ) {
217 217
                 continue;
218 218
             }
219 219
 
220
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
-                $ip = trim($ip); // just to be safe
220
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
221
+                $ip = trim( $ip ); // just to be safe
222 222
 
223
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
223
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
224 224
                     return $ip;
225 225
                 }
226 226
             }
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
     }
231 231
 
232 232
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
-        if ( strpos($param, '[') ) {
234
-            $params = explode('[', $param);
233
+        if ( strpos( $param, '[' ) ) {
234
+            $params = explode( '[', $param );
235 235
             $param = $params[0];
236 236
         }
237 237
 
238 238
 		if ( $src == 'get' ) {
239
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
239
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
240
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
241
+                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) );
242 242
             }
243 243
 			self::sanitize_value( $sanitize, $value );
244 244
 		} else {
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 
248 248
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
249 249
             foreach ( $params as $k => $p ) {
250
-                if ( ! $k || ! is_array($value) ) {
250
+                if ( ! $k || ! is_array( $value ) ) {
251 251
                     continue;
252 252
                 }
253 253
 
254
-                $p = trim($p, ']');
255
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
254
+                $p = trim( $p, ']' );
255
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
256 256
             }
257 257
         }
258 258
 
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$value = $args['default'];
293 293
 		if ( $args['type'] == 'get' ) {
294
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
295
-				$value = $_GET[ $args['param'] ];
294
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
295
+				$value = $_GET[$args['param']];
296 296
 			}
297 297
 		} else if ( $args['type'] == 'post' ) {
298
-			if ( isset( $_POST[ $args['param'] ] ) ) {
299
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
298
+			if ( isset( $_POST[$args['param']] ) ) {
299
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
300 300
 			}
301 301
 		} else {
302
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
303
-				$value = $_REQUEST[ $args['param'] ];
302
+			if ( isset( $_REQUEST[$args['param']] ) ) {
303
+				$value = $_REQUEST[$args['param']];
304 304
 			}
305 305
 		}
306 306
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 			if ( is_array( $value ) ) {
329 329
 				$temp_values = $value;
330 330
 				foreach ( $temp_values as $k => $v ) {
331
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
331
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
332 332
 				}
333 333
 			} else {
334 334
 				$value = call_user_func( $sanitize, $value );
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
     public static function sanitize_request( $sanitize_method, &$values ) {
340 340
         $temp_values = $values;
341 341
         foreach ( $temp_values as $k => $val ) {
342
-            if ( isset( $sanitize_method[ $k ] ) ) {
343
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
342
+            if ( isset( $sanitize_method[$k] ) ) {
343
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
344 344
             }
345 345
         }
346 346
     }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	public static function sanitize_array( &$values ) {
349 349
 		$temp_values = $values;
350 350
 		foreach ( $temp_values as $k => $val ) {
351
-			$values[ $k ] = wp_kses_post( $val );
351
+			$values[$k] = wp_kses_post( $val );
352 352
 		}
353 353
 	}
354 354
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
 		$allowed_html = array();
373 373
 		foreach ( $allowed as $a ) {
374
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
374
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
375 375
 		}
376 376
 
377 377
 		return wp_kses( $value, $allowed_html );
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      * @since 2.0
383 383
      */
384 384
     public static function remove_get_action() {
385
-        if ( ! isset($_GET) ) {
385
+        if ( ! isset( $_GET ) ) {
386 386
             return;
387 387
         }
388 388
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
         }
405 405
 
406 406
         global $wp_query;
407
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
-            $value = $wp_query->query_vars[ $param ];
407
+        if ( isset( $wp_query->query_vars[$param] ) ) {
408
+            $value = $wp_query->query_vars[$param];
409 409
         }
410 410
 
411 411
         return $value;
@@ -434,19 +434,19 @@  discard block
 block discarded – undo
434 434
      * @return mixed $results The cache or query results
435 435
      */
436 436
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
-        $results = wp_cache_get($cache_key, $group);
438
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
437
+        $results = wp_cache_get( $cache_key, $group );
438
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
439 439
             return $results;
440 440
         }
441 441
 
442 442
         if ( 'get_posts' == $type ) {
443
-            $results = get_posts($query);
443
+            $results = get_posts( $query );
444 444
 		} else if ( 'get_associative_results' == $type ) {
445 445
 			global $wpdb;
446 446
 			$results = $wpdb->get_results( $query, OBJECT_K );
447 447
         } else {
448 448
             global $wpdb;
449
-            $results = $wpdb->{$type}($query);
449
+            $results = $wpdb->{$type}( $query );
450 450
         }
451 451
 
452 452
 		self::set_cache( $cache_key, $results, $group, $time );
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	public static function add_key_to_group_cache( $key, $group ) {
469 469
 		$cached = self::get_group_cached_keys( $group );
470
-		$cached[ $key ] = $key;
470
+		$cached[$key] = $key;
471 471
 		wp_cache_set( 'cached_keys', $cached, $group, 300 );
472 472
 	}
473 473
 
@@ -494,9 +494,9 @@  discard block
 block discarded – undo
494 494
         }
495 495
 
496 496
         // then check the transient
497
-        $results = get_transient($cache_key);
497
+        $results = get_transient( $cache_key );
498 498
         if ( $results ) {
499
-            wp_cache_set($cache_key, $results);
499
+            wp_cache_set( $cache_key, $results );
500 500
         }
501 501
 
502 502
         return $results;
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
      * @param string $cache_key
508 508
      */
509 509
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
510
-		delete_transient($cache_key);
510
+		delete_transient( $cache_key );
511 511
 		wp_cache_delete( $cache_key, $group );
512 512
 	}
513 513
 
@@ -551,17 +551,17 @@  discard block
 block discarded – undo
551 551
     }
552 552
 
553 553
     public static function get_pages() {
554
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
554
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
555 555
     }
556 556
 
557 557
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
558 558
         $pages = self::get_pages();
559 559
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
560 560
     ?>
561
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
561
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
562 562
             <option value=""> </option>
563 563
             <?php foreach ( $pages as $page ) { ?>
564
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
564
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
565 565
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
566 566
 				</option>
567 567
             <?php } ?>
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
     }
571 571
 
572 572
 	public static function post_edit_link( $post_id ) {
573
-        $post = get_post($post_id);
573
+        $post = get_post( $post_id );
574 574
         if ( $post ) {
575 575
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
576 576
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -580,17 +580,17 @@  discard block
 block discarded – undo
580 580
 
581 581
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
582 582
     ?>
583
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
583
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
584 584
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
585 585
             ?> class="frm_multiselect">
586
-            <?php self::roles_options($capability); ?>
586
+            <?php self::roles_options( $capability ); ?>
587 587
         </select>
588 588
     <?php
589 589
     }
590 590
 
591 591
 	public static function roles_options( $capability ) {
592 592
         global $frm_vars;
593
-        if ( isset($frm_vars['editable_roles']) ) {
593
+        if ( isset( $frm_vars['editable_roles'] ) ) {
594 594
             $editable_roles = $frm_vars['editable_roles'];
595 595
         } else {
596 596
             $editable_roles = get_editable_roles();
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
         }
599 599
 
600 600
         foreach ( $editable_roles as $role => $details ) {
601
-            $name = translate_user_role($details['name'] ); ?>
602
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
601
+            $name = translate_user_role( $details['name'] ); ?>
602
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
603 603
 <?php
604
-            unset($role, $details);
604
+            unset( $role, $details );
605 605
         }
606 606
     }
607 607
 
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
     public static function maybe_add_permissions() {
658 658
 		self::force_capability( 'frm_view_entries' );
659 659
 
660
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
660
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
661 661
             return;
662 662
         }
663 663
 
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
         $frm_roles = self::frm_capabilities();
667 667
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
668 668
 			$user->add_cap( $frm_role );
669
-            unset($frm_role, $frm_role_description);
669
+            unset( $frm_role, $frm_role_description );
670 670
         }
671 671
     }
672 672
 
@@ -691,12 +691,12 @@  discard block
 block discarded – undo
691 691
      * @param string $permission
692 692
      */
693 693
 	public static function permission_check( $permission, $show_message = 'show' ) {
694
-        $permission_error = self::permission_nonce_error($permission);
694
+        $permission_error = self::permission_nonce_error( $permission );
695 695
         if ( $permission_error !== false ) {
696 696
             if ( 'hide' == $show_message ) {
697 697
                 $permission_error = '';
698 698
             }
699
-            wp_die($permission_error);
699
+            wp_die( $permission_error );
700 700
         }
701 701
     }
702 702
 
@@ -713,11 +713,11 @@  discard block
 block discarded – undo
713 713
 		}
714 714
 
715 715
 		$error = false;
716
-        if ( empty($nonce_name) ) {
716
+        if ( empty( $nonce_name ) ) {
717 717
             return $error;
718 718
         }
719 719
 
720
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
720
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
721 721
             $frm_settings = self::get_settings();
722 722
             $error = $frm_settings->admin_permission;
723 723
         }
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 			} else {
798 798
 				foreach ( $value as $k => $v ) {
799 799
 					if ( ! is_array( $v ) ) {
800
-						$value[ $k ] = call_user_func( $original_function, $v );
800
+						$value[$k] = call_user_func( $original_function, $v );
801 801
 					}
802 802
 				}
803 803
 			}
@@ -818,11 +818,11 @@  discard block
 block discarded – undo
818 818
 	public static function array_flatten( $array, $keys = 'keep' ) {
819 819
         $return = array();
820 820
         foreach ( $array as $key => $value ) {
821
-            if ( is_array($value) ) {
821
+            if ( is_array( $value ) ) {
822 822
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
823 823
             } else {
824 824
 				if ( $keys == 'keep' ) {
825
-					$return[ $key ] = $value;
825
+					$return[$key] = $value;
826 826
 				} else {
827 827
 					$return[] = $value;
828 828
 				}
@@ -845,8 +845,8 @@  discard block
 block discarded – undo
845 845
      * @since 2.0
846 846
      */
847 847
 	public static function use_wpautop( $content ) {
848
-        if ( apply_filters('frm_use_wpautop', true) ) {
849
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
848
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
849
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
850 850
         }
851 851
         return $content;
852 852
     }
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
      * @return string The base Google APIS url for the current version of jQuery UI
865 865
      */
866 866
     public static function jquery_ui_base_url() {
867
-		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core', '1.11.4');
868
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
867
+		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
868
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
869 869
         return $url;
870 870
     }
871 871
 
@@ -880,11 +880,11 @@  discard block
 block discarded – undo
880 880
 
881 881
         $ver = 0;
882 882
 
883
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
883
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
884 884
             return $ver;
885 885
         }
886 886
 
887
-        $query = $wp_scripts->registered[ $handle ];
887
+        $query = $wp_scripts->registered[$handle];
888 888
     	if ( is_object( $query ) ) {
889 889
     	    $ver = $query->ver;
890 890
     	}
@@ -897,36 +897,36 @@  discard block
 block discarded – undo
897 897
     }
898 898
 
899 899
 	public static function get_user_id_param( $user_id ) {
900
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
900
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
901 901
             return $user_id;
902 902
         }
903 903
 
904 904
 		if ( $user_id == 'current' ) {
905 905
 			$user_id = get_current_user_id();
906 906
 		} else {
907
-            if ( is_email($user_id) ) {
908
-                $user = get_user_by('email', $user_id);
907
+            if ( is_email( $user_id ) ) {
908
+                $user = get_user_by( 'email', $user_id );
909 909
             } else {
910
-                $user = get_user_by('login', $user_id);
910
+                $user = get_user_by( 'login', $user_id );
911 911
             }
912 912
 
913 913
             if ( $user ) {
914 914
                 $user_id = $user->ID;
915 915
             }
916
-            unset($user);
916
+            unset( $user );
917 917
         }
918 918
 
919 919
         return $user_id;
920 920
     }
921 921
 
922 922
 	public static function get_file_contents( $filename, $atts = array() ) {
923
-        if ( ! is_file($filename) ) {
923
+        if ( ! is_file( $filename ) ) {
924 924
             return false;
925 925
         }
926 926
 
927
-        extract($atts);
927
+        extract( $atts );
928 928
         ob_start();
929
-        include($filename);
929
+        include( $filename );
930 930
         $contents = ob_get_contents();
931 931
         ob_end_clean();
932 932
         return $contents;
@@ -942,27 +942,27 @@  discard block
 block discarded – undo
942 942
         $key = '';
943 943
 
944 944
         if ( ! empty( $name ) ) {
945
-            $key = sanitize_key($name);
945
+            $key = sanitize_key( $name );
946 946
         }
947 947
 
948 948
 		if ( empty( $key ) ) {
949
-            $max_slug_value = pow(36, $num_chars);
949
+            $max_slug_value = pow( 36, $num_chars );
950 950
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
951
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
951
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
952 952
         }
953 953
 
954
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
954
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
955 955
 			$key = $key . 'a';
956 956
         }
957 957
 
958 958
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
959 959
 
960
-        if ( $key_check || is_numeric($key_check) ) {
960
+        if ( $key_check || is_numeric( $key_check ) ) {
961 961
             $suffix = 2;
962 962
 			do {
963 963
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
964 964
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
965
-				$suffix++;
965
+				$suffix ++;
966 966
 			} while ( $key_check || is_numeric( $key_check ) );
967 967
 			$key = $alt_post_name;
968 968
         }
@@ -979,32 +979,32 @@  discard block
 block discarded – undo
979 979
             return false;
980 980
         }
981 981
 
982
-        if ( empty($post_values) ) {
983
-            $post_values = stripslashes_deep($_POST);
982
+        if ( empty( $post_values ) ) {
983
+            $post_values = stripslashes_deep( $_POST );
984 984
         }
985 985
 
986 986
 		$values = array( 'id' => $record->id, 'fields' => array() );
987 987
 
988 988
 		foreach ( array( 'name', 'description' ) as $var ) {
989
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
990
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
991
-            unset($var, $default_val);
989
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
990
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
991
+            unset( $var, $default_val );
992 992
         }
993 993
 
994
-        $values['description'] = self::use_wpautop($values['description']);
994
+        $values['description'] = self::use_wpautop( $values['description'] );
995 995
         $frm_settings = self::get_settings();
996
-        $is_form_builder = self::is_admin_page('formidable' );
996
+        $is_form_builder = self::is_admin_page( 'formidable' );
997 997
 
998 998
         foreach ( (array) $fields as $field ) {
999 999
             // Make sure to filter default values (for placeholder text), but not on the form builder page
1000 1000
             if ( ! $is_form_builder ) {
1001
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1001
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
1002 1002
             }
1003 1003
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1004
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1004
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1005 1005
         }
1006 1006
 
1007
-        self::fill_form_opts($record, $table, $post_values, $values);
1007
+        self::fill_form_opts( $record, $table, $post_values, $values );
1008 1008
 
1009 1009
         if ( $table == 'entries' ) {
1010 1010
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
         if ( $args['default'] ) {
1022 1022
             $meta_value = $field->default_value;
1023 1023
         } else {
1024
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1025
-                if ( ! isset($field->field_options['custom_field']) ) {
1024
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1025
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1026 1026
                     $field->field_options['custom_field'] = '';
1027 1027
                 }
1028 1028
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) );
@@ -1031,8 +1031,8 @@  discard block
 block discarded – undo
1031 1031
             }
1032 1032
         }
1033 1033
 
1034
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1035
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1034
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1035
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1036 1036
 
1037 1037
         $field_array = array(
1038 1038
             'id'            => $field->id,
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
             'default_value' => $field->default_value,
1041 1041
             'name'          => $field->name,
1042 1042
             'description'   => $field->description,
1043
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1043
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1044 1044
             'options'       => $field->options,
1045 1045
             'required'      => $field->required,
1046 1046
             'field_key'     => $field->field_key,
@@ -1050,40 +1050,40 @@  discard block
 block discarded – undo
1050 1050
         );
1051 1051
 
1052 1052
         $args['field_type'] = $field_type;
1053
-        self::fill_field_opts($field, $field_array, $args);
1053
+        self::fill_field_opts( $field, $field_array, $args );
1054 1054
 		// Track the original field's type
1055 1055
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1056 1056
 
1057 1057
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1058 1058
 
1059
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1059
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1060 1060
             $field_array['unique_msg'] = '';
1061 1061
         }
1062 1062
 
1063 1063
         $field_array = array_merge( $field->field_options, $field_array );
1064 1064
 
1065
-        $values['fields'][ $field->id ] = $field_array;
1065
+        $values['fields'][$field->id] = $field_array;
1066 1066
     }
1067 1067
 
1068 1068
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1069 1069
         $post_values = $args['post_values'];
1070
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1070
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1071 1071
 
1072 1072
         foreach ( $opt_defaults as $opt => $default_opt ) {
1073
-			$field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt );
1074
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1075
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1076
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1073
+			$field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt );
1074
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1075
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1076
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1077 1077
                 if ( $args['field_type'] == 'captcha' ) {
1078
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1078
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1079 1079
                 } else {
1080
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1080
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1081 1081
                 }
1082 1082
             }
1083 1083
         }
1084 1084
 
1085 1085
         if ( $field_array['custom_html'] == '' ) {
1086
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1086
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1087 1087
         }
1088 1088
     }
1089 1089
 
@@ -1102,18 +1102,18 @@  discard block
 block discarded – undo
1102 1102
             return;
1103 1103
         }
1104 1104
 
1105
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1105
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1106 1106
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1107 1107
 
1108
-        if ( ! is_array($form->options) ) {
1108
+        if ( ! is_array( $form->options ) ) {
1109 1109
             return;
1110 1110
         }
1111 1111
 
1112 1112
         foreach ( $form->options as $opt => $value ) {
1113
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1113
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1114 1114
         }
1115 1115
 
1116
-        self::fill_form_defaults($post_values, $values);
1116
+        self::fill_form_defaults( $post_values, $values );
1117 1117
     }
1118 1118
 
1119 1119
     /**
@@ -1123,11 +1123,11 @@  discard block
 block discarded – undo
1123 1123
         $form_defaults = FrmFormsHelper::get_default_opts();
1124 1124
 
1125 1125
         foreach ( $form_defaults as $opt => $default ) {
1126
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1127
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1126
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1127
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1128 1128
             }
1129 1129
 
1130
-            unset($opt, $defaut);
1130
+            unset( $opt, $defaut );
1131 1131
         }
1132 1132
 
1133 1133
 		if ( ! isset( $values['custom_style'] ) ) {
@@ -1135,10 +1135,10 @@  discard block
 block discarded – undo
1135 1135
 		}
1136 1136
 
1137 1137
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1138
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1139
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1138
+			if ( ! isset( $values[$h . '_html'] ) ) {
1139
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1140 1140
             }
1141
-            unset($h);
1141
+            unset( $h );
1142 1142
         }
1143 1143
     }
1144 1144
 
@@ -1169,9 +1169,9 @@  discard block
 block discarded – undo
1169 1169
         }
1170 1170
     ?>
1171 1171
 <li>
1172
-    <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1173
-    <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a>
1174
-    <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a>
1172
+    <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1173
+    <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a>
1174
+    <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a>
1175 1175
 </li>
1176 1176
     <?php
1177 1177
     }
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
             return '';
1190 1190
         } else if ( $length <= 10 ) {
1191 1191
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1192
-            return $sub . (($length < $original_len) ? $continue : '');
1192
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1193 1193
         }
1194 1194
 
1195 1195
         $sub = '';
@@ -1198,23 +1198,23 @@  discard block
 block discarded – undo
1198 1198
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1199 1199
 
1200 1200
 		foreach ( $words as $word ) {
1201
-            $part = (($sub != '') ? ' ' : '') . $word;
1201
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1202 1202
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1203
-            if ( $total_len > $length && str_word_count($sub) ) {
1203
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1204 1204
                 break;
1205 1205
             }
1206 1206
 
1207 1207
             $sub .= $part;
1208 1208
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1209 1209
 
1210
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1210
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1211 1211
                 break;
1212 1212
             }
1213 1213
 
1214
-            unset($total_len, $word);
1214
+            unset( $total_len, $word );
1215 1215
         }
1216 1216
 
1217
-        return $sub . (($len < $original_len) ? $continue : '');
1217
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1218 1218
     }
1219 1219
 
1220 1220
 	public static function mb_function( $function_names, $args ) {
@@ -1227,17 +1227,17 @@  discard block
 block discarded – undo
1227 1227
 	}
1228 1228
 
1229 1229
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1230
-        if ( empty($date) ) {
1230
+        if ( empty( $date ) ) {
1231 1231
             return $date;
1232 1232
         }
1233 1233
 
1234
-        if ( empty($date_format) ) {
1235
-            $date_format = get_option('date_format');
1234
+        if ( empty( $date_format ) ) {
1235
+            $date_format = get_option( 'date_format' );
1236 1236
         }
1237 1237
 
1238
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1238
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1239 1239
             $frmpro_settings = new FrmProSettings();
1240
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1240
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1241 1241
         }
1242 1242
 
1243 1243
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
 
1253 1253
 	private static function add_time_to_date( $time_format, $date ) {
1254 1254
 		if ( empty( $time_format ) ) {
1255
-			$time_format = get_option('time_format');
1255
+			$time_format = get_option( 'time_format' );
1256 1256
 		}
1257 1257
 
1258 1258
 		$trimmed_format = trim( $time_format );
@@ -1298,10 +1298,10 @@  discard block
 block discarded – undo
1298 1298
 		$time_strings = self::get_time_strings();
1299 1299
 
1300 1300
 		foreach ( $time_strings as $k => $v ) {
1301
-			if ( $diff[ $k ] ) {
1302
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1301
+			if ( $diff[$k] ) {
1302
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1303 1303
 			} else {
1304
-				unset( $time_strings[ $k ] );
1304
+				unset( $time_strings[$k] );
1305 1305
 			}
1306 1306
 		}
1307 1307
 
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
      */
1341 1341
 	public static function esc_like( $term ) {
1342 1342
         global $wpdb;
1343
-        if ( method_exists($wpdb, 'esc_like') ) {
1343
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1344 1344
 			// WP 4.0
1345 1345
             $term = $wpdb->esc_like( $term );
1346 1346
         } else {
@@ -1354,17 +1354,17 @@  discard block
 block discarded – undo
1354 1354
      * @param string $order_query
1355 1355
      */
1356 1356
 	public static function esc_order( $order_query ) {
1357
-        if ( empty($order_query) ) {
1357
+        if ( empty( $order_query ) ) {
1358 1358
             return '';
1359 1359
         }
1360 1360
 
1361 1361
         // remove ORDER BY before santizing
1362
-        $order_query = strtolower($order_query);
1363
-        if ( strpos($order_query, 'order by') !== false ) {
1364
-            $order_query = str_replace('order by', '', $order_query);
1362
+        $order_query = strtolower( $order_query );
1363
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1364
+            $order_query = str_replace( 'order by', '', $order_query );
1365 1365
         }
1366 1366
 
1367
-        $order_query = explode(' ', trim($order_query));
1367
+        $order_query = explode( ' ', trim( $order_query ) );
1368 1368
 
1369 1369
         $order_fields = array(
1370 1370
             'id', 'form_key', 'name', 'description',
@@ -1372,13 +1372,13 @@  discard block
 block discarded – undo
1372 1372
             'default_template', 'status', 'created_at',
1373 1373
         );
1374 1374
 
1375
-        $order = trim(trim(reset($order_query), ','));
1376
-        if ( ! in_array($order, $order_fields) ) {
1375
+        $order = trim( trim( reset( $order_query ), ',' ) );
1376
+        if ( ! in_array( $order, $order_fields ) ) {
1377 1377
             return '';
1378 1378
         }
1379 1379
 
1380 1380
         $order_by = '';
1381
-        if ( count($order_query) > 1 ) {
1381
+        if ( count( $order_query ) > 1 ) {
1382 1382
 			$order_by = end( $order_query );
1383 1383
 			self::esc_order_by( $order_by );
1384 1384
         }
@@ -1400,23 +1400,23 @@  discard block
 block discarded – undo
1400 1400
      * @param string $limit
1401 1401
      */
1402 1402
 	public static function esc_limit( $limit ) {
1403
-        if ( empty($limit) ) {
1403
+        if ( empty( $limit ) ) {
1404 1404
             return '';
1405 1405
         }
1406 1406
 
1407
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1408
-        if ( is_numeric($limit) ) {
1407
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1408
+        if ( is_numeric( $limit ) ) {
1409 1409
 			return ' LIMIT ' . $limit;
1410 1410
         }
1411 1411
 
1412
-        $limit = explode(',', trim($limit));
1412
+        $limit = explode( ',', trim( $limit ) );
1413 1413
         foreach ( $limit as $k => $l ) {
1414 1414
             if ( is_numeric( $l ) ) {
1415
-                $limit[ $k ] = $l;
1415
+                $limit[$k] = $l;
1416 1416
             }
1417 1417
         }
1418 1418
 
1419
-        $limit = implode(',', $limit);
1419
+        $limit = implode( ',', $limit );
1420 1420
 		return ' LIMIT ' . $limit;
1421 1421
     }
1422 1422
 
@@ -1425,12 +1425,12 @@  discard block
 block discarded – undo
1425 1425
      * @since 2.0
1426 1426
      */
1427 1427
     public static function prepare_array_values( $array, $type = '%s' ) {
1428
-        $placeholders = array_fill(0, count($array), $type);
1429
-        return implode(', ', $placeholders);
1428
+        $placeholders = array_fill( 0, count( $array ), $type );
1429
+        return implode( ', ', $placeholders );
1430 1430
     }
1431 1431
 
1432 1432
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1433
-        if ( empty($where) ) {
1433
+        if ( empty( $where ) ) {
1434 1434
             return '';
1435 1435
         }
1436 1436
 
@@ -1471,19 +1471,19 @@  discard block
 block discarded – undo
1471 1471
 	public static function json_to_array( $json_vars ) {
1472 1472
         $vars = array();
1473 1473
         foreach ( $json_vars as $jv ) {
1474
-            $jv_name = explode('[', $jv['name']);
1475
-            $last = count($jv_name) - 1;
1474
+            $jv_name = explode( '[', $jv['name'] );
1475
+            $last = count( $jv_name ) - 1;
1476 1476
             foreach ( $jv_name as $p => $n ) {
1477
-                $name = trim($n, ']');
1478
-                if ( ! isset($l1) ) {
1477
+                $name = trim( $n, ']' );
1478
+                if ( ! isset( $l1 ) ) {
1479 1479
                     $l1 = $name;
1480 1480
                 }
1481 1481
 
1482
-                if ( ! isset($l2) ) {
1482
+                if ( ! isset( $l2 ) ) {
1483 1483
                     $l2 = $name;
1484 1484
                 }
1485 1485
 
1486
-                if ( ! isset($l3) ) {
1486
+                if ( ! isset( $l3 ) ) {
1487 1487
                     $l3 = $name;
1488 1488
                 }
1489 1489
 
@@ -1497,24 +1497,24 @@  discard block
 block discarded – undo
1497 1497
 
1498 1498
                     case 1:
1499 1499
                         $l2 = $name;
1500
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1500
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1501 1501
                     break;
1502 1502
 
1503 1503
                     case 2:
1504 1504
                         $l3 = $name;
1505
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1505
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1506 1506
                     break;
1507 1507
 
1508 1508
                     case 3:
1509 1509
                         $l4 = $name;
1510
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1510
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1511 1511
                     break;
1512 1512
                 }
1513 1513
 
1514
-                unset($this_val, $n);
1514
+                unset( $this_val, $n );
1515 1515
             }
1516 1516
 
1517
-            unset($last, $jv);
1517
+            unset( $last, $jv );
1518 1518
         }
1519 1519
 
1520 1520
         return $vars;
@@ -1527,8 +1527,8 @@  discard block
 block discarded – undo
1527 1527
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1528 1528
         if ( $name == '' ) {
1529 1529
             $vars[] = $val;
1530
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1531
-            $vars[ $l1 ] = $val;
1530
+        } else if ( ! isset( $vars[$l1] ) ) {
1531
+            $vars[$l1] = $val;
1532 1532
         }
1533 1533
     }
1534 1534
 
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
             'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1544 1544
         );
1545 1545
 
1546
-        if ( ! isset( $tooltips[ $name ] ) ) {
1546
+        if ( ! isset( $tooltips[$name] ) ) {
1547 1547
             return;
1548 1548
         }
1549 1549
 
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
             echo ' class="frm_help"';
1554 1554
         }
1555 1555
 
1556
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1556
+		echo ' title="' . esc_attr( $tooltips[$name] );
1557 1557
 
1558 1558
         if ( 'open' != $class ) {
1559 1559
             echo '"';
@@ -1605,13 +1605,13 @@  discard block
 block discarded – undo
1605 1605
     }
1606 1606
 
1607 1607
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1608
-		if ( ! isset( $post_content[ $key ] ) ) {
1608
+		if ( ! isset( $post_content[$key] ) ) {
1609 1609
 			return;
1610 1610
 		}
1611 1611
 
1612 1612
 		if ( is_array( $val ) ) {
1613 1613
 			foreach ( $val as $k1 => $v1 ) {
1614
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1614
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1615 1615
 				unset( $k1, $v1 );
1616 1616
 			}
1617 1617
 		} else {
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 			$val = stripslashes( $val );
1620 1620
 
1621 1621
 			// Add backslashes before double quotes and forward slashes only
1622
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1622
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1623 1623
 		}
1624 1624
 	}
1625 1625
 
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1637 1637
 
1638 1638
 		if ( empty( $settings['ID'] ) ) {
1639
-			unset( $settings['ID']);
1639
+			unset( $settings['ID'] );
1640 1640
 		}
1641 1641
 
1642 1642
 		// delete all caches for this group
@@ -1670,17 +1670,17 @@  discard block
 block discarded – undo
1670 1670
 	}
1671 1671
 
1672 1672
 	public static function maybe_json_decode( $string ) {
1673
-        if ( is_array($string) ) {
1673
+        if ( is_array( $string ) ) {
1674 1674
             return $string;
1675 1675
         }
1676 1676
 
1677
-        $new_string = json_decode($string, true);
1678
-        if ( function_exists('json_last_error') ) {
1677
+        $new_string = json_decode( $string, true );
1678
+        if ( function_exists( 'json_last_error' ) ) {
1679 1679
 			// php 5.3+
1680 1680
             if ( json_last_error() == JSON_ERROR_NONE ) {
1681 1681
                 $string = $new_string;
1682 1682
             }
1683
-        } else if ( isset($new_string) ) {
1683
+        } else if ( isset( $new_string ) ) {
1684 1684
 			// php < 5.3 fallback
1685 1685
             $string = $new_string;
1686 1686
         }
@@ -1696,11 +1696,11 @@  discard block
 block discarded – undo
1696 1696
 	public static function maybe_highlight_menu( $post_type ) {
1697 1697
         global $post;
1698 1698
 
1699
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1699
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1700 1700
             return;
1701 1701
         }
1702 1702
 
1703
-        if ( is_object($post) && $post->post_type != $post_type ) {
1703
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1704 1704
             return;
1705 1705
         }
1706 1706
 
@@ -1801,11 +1801,11 @@  discard block
 block discarded – undo
1801 1801
         $frm_version = self::plugin_version();
1802 1802
 
1803 1803
         // check if Formidable meets minimum requirements
1804
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1804
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1805 1805
             return;
1806 1806
         }
1807 1807
 
1808
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1808
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1809 1809
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1810 1810
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1811 1811
         '</div></td></tr>';
@@ -1813,38 +1813,38 @@  discard block
 block discarded – undo
1813 1813
 
1814 1814
     public static function locales( $type = 'date' ) {
1815 1815
         $locales = array(
1816
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1817
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1818
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1816
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1817
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1818
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1819 1819
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1820
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1821
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1820
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1821
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1822 1822
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1823
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1824
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1823
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1824
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1825 1825
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1826
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1826
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1827 1827
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1828
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1828
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1829 1829
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1830
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1830
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1831 1831
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1832
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1833
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1834
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1835
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1836
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1832
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1833
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1834
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1835
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1836
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1837 1837
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1838
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1838
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1839 1839
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1840 1840
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1841
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1841
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1842 1842
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1843
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1843
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1844 1844
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1845
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1846
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1847
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1845
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1846
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1847
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1848 1848
         );
1849 1849
 
1850 1850
         if ( $type == 'captcha' ) {
@@ -1863,8 +1863,8 @@  discard block
 block discarded – undo
1863 1863
             );
1864 1864
         }
1865 1865
 
1866
-        $locales = array_diff_key($locales, array_flip($unset));
1867
-        $locales = apply_filters('frm_locales', $locales);
1866
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1867
+        $locales = apply_filters( 'frm_locales', $locales );
1868 1868
 
1869 1869
         return $locales;
1870 1870
     }
Please login to merge, or discard this patch.