Completed
Push — master ( 5d7e04...7d6f01 )
by Jamie
03:33
created
classes/models/FrmStyle.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7
-	 * @param int|string $id The id of the stylsheet or 'default'
7
+	 * @param integer $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10 10
         $this->id = $id;
@@ -120,6 +120,9 @@  discard block
 block discarded – undo
120 120
         set_transient('frmpro_css', $css);
121 121
 	}
122 122
 
123
+	/**
124
+	 * @param string $filename
125
+	 */
123 126
 	private function get_css_content( $filename ) {
124 127
 		$css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
125 128
 
Please login to merge, or discard this patch.
Indentation   +275 added lines, -275 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,42 +54,42 @@  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 ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
81
-                    //if is a color
81
+					//if is a color
82 82
 					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
83 83
 				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
84 84
 					$new_instance['post_content'][ $setting ] = 0;
85
-                } else if ( $setting == 'font' ) {
86
-                	$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
87
-                }
88
-            }
85
+				} else if ( $setting == 'font' ) {
86
+					$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
87
+				}
88
+			}
89 89
 
90 90
 			$all_instances[ $number ] = $new_instance;
91 91
 
92
-            $action_ids[] = $this->save($new_instance);
92
+			$action_ids[] = $this->save($new_instance);
93 93
 
94 94
  		}
95 95
 
@@ -98,27 +98,27 @@  discard block
 block discarded – undo
98 98
  		return $action_ids;
99 99
  	}
100 100
 
101
-    /**
102
-     * Create static css file
103
-     */
101
+	/**
102
+	 * Create static css file
103
+	 */
104 104
 	public function save_settings() {
105 105
 		$filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
106 106
 		update_option( 'frm_last_style_update', date('njGi') );
107 107
 
108
-        if ( ! is_file($filename) ) {
109
-            return;
110
-        }
108
+		if ( ! is_file($filename) ) {
109
+			return;
110
+		}
111 111
 
112 112
 		$css = $this->get_css_content( $filename );
113 113
 
114 114
 		$create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) );
115 115
 		$create_file->create_file( $css );
116 116
 
117
-        update_option('frmpro_css', $css);
117
+		update_option('frmpro_css', $css);
118 118
 
119 119
 		$this->clear_cache();
120 120
 
121
-        set_transient('frmpro_css', $css);
121
+		set_transient('frmpro_css', $css);
122 122
 	}
123 123
 
124 124
 	private function get_css_content( $filename ) {
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		$saving = true;
128 128
 		$frm_style = $this;
129 129
 
130
-        ob_start();
131
-        include( $filename );
130
+		ob_start();
131
+		include( $filename );
132 132
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
133
-        ob_end_clean();
133
+		ob_end_clean();
134 134
 
135 135
 		return $css;
136 136
 	}
@@ -150,272 +150,272 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 
152 152
 	public function destroy( $id ) {
153
-        return wp_delete_post($id);
154
-    }
153
+		return wp_delete_post($id);
154
+	}
155 155
 
156
-    public function get_one() {
157
-        if ( 'default' == $this->id ) {
158
-            $style = $this->get_default_style();
159
-            if ( $style ) {
160
-                $this->id = $style->ID;
161
-            } else {
162
-                $this->id = 0;
163
-            }
164
-            return $style;
165
-        }
156
+	public function get_one() {
157
+		if ( 'default' == $this->id ) {
158
+			$style = $this->get_default_style();
159
+			if ( $style ) {
160
+				$this->id = $style->ID;
161
+			} else {
162
+				$this->id = 0;
163
+			}
164
+			return $style;
165
+		}
166 166
 
167
-        $style = get_post($this->id);
167
+		$style = get_post($this->id);
168 168
 
169
-        if ( ! $style ) {
170
-            return $style;
171
-        }
169
+		if ( ! $style ) {
170
+			return $style;
171
+		}
172 172
 
173
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
173
+		$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
174 174
 
175
-        $default_values = $this->get_defaults();
175
+		$default_values = $this->get_defaults();
176 176
 
177
-        // fill default values
178
-        $style->post_content = $this->override_defaults($style->post_content);
179
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
177
+		// fill default values
178
+		$style->post_content = $this->override_defaults($style->post_content);
179
+		$style->post_content = wp_parse_args( $style->post_content, $default_values);
180 180
 
181
-        return $style;
182
-    }
181
+		return $style;
182
+	}
183 183
 
184
-    public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
185
-        $post_atts = array(
184
+	public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
185
+		$post_atts = array(
186 186
 			'post_type'   => FrmStylesController::$post_type,
187 187
 			'post_status' => 'publish',
188 188
 			'numberposts' => $limit,
189 189
 			'orderby'     => $orderby,
190 190
 			'order'       => $order,
191
-        );
191
+		);
192 192
 
193
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
193
+		$temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
194 194
 
195
-        if ( empty($temp_styles) ) {
196
-            global $wpdb;
197
-            // make sure there wasn't a conflict with the query
195
+		if ( empty($temp_styles) ) {
196
+			global $wpdb;
197
+			// make sure there wasn't a conflict with the query
198 198
 			$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' );
199
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
200
-
201
-            if ( empty($temp_styles) ) {
202
-                // create a new style if there are none
203
-         		$new = $this->get_new();
204
-         		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
205
-         		$new->menu_order = 1;
206
-         		$new = $this->save( (array) $new);
207
-         		$this->update('default');
208
-
209
-                $post_atts['include'] = $new;
210
-
211
-                $temp_styles = get_posts( $post_atts );
212
-            }
213
-        }
214
-
215
-        $default_values = $this->get_defaults();
216
-        $default_style = false;
217
-
218
-        $styles = array();
219
-        foreach ( $temp_styles as $style ) {
220
-            $this->id = $style->ID;
221
-            if ( $style->menu_order ) {
222
-                if ( $default_style ) {
223
-                    // only return one default
224
-                    $style->menu_order = 0;
225
-                } else {
226
-                    // check for a default style
227
-                    $default_style = $style->ID;
228
-                }
229
-            }
230
-
231
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
232
-
233
-            // fill default values
234
-            $style->post_content = $this->override_defaults($style->post_content);
235
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
199
+			$temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
200
+
201
+			if ( empty($temp_styles) ) {
202
+				// create a new style if there are none
203
+		 		$new = $this->get_new();
204
+		 		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
205
+		 		$new->menu_order = 1;
206
+		 		$new = $this->save( (array) $new);
207
+		 		$this->update('default');
208
+
209
+				$post_atts['include'] = $new;
210
+
211
+				$temp_styles = get_posts( $post_atts );
212
+			}
213
+		}
214
+
215
+		$default_values = $this->get_defaults();
216
+		$default_style = false;
217
+
218
+		$styles = array();
219
+		foreach ( $temp_styles as $style ) {
220
+			$this->id = $style->ID;
221
+			if ( $style->menu_order ) {
222
+				if ( $default_style ) {
223
+					// only return one default
224
+					$style->menu_order = 0;
225
+				} else {
226
+					// check for a default style
227
+					$default_style = $style->ID;
228
+				}
229
+			}
230
+
231
+			$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
232
+
233
+			// fill default values
234
+			$style->post_content = $this->override_defaults($style->post_content);
235
+			$style->post_content = wp_parse_args( $style->post_content, $default_values);
236 236
 
237 237
 			$styles[ $style->ID ] = $style;
238
-        }
238
+		}
239 239
 
240
-        if ( ! $default_style ) {
241
-            $default_style = reset($styles);
240
+		if ( ! $default_style ) {
241
+			$default_style = reset($styles);
242 242
 			$styles[ $default_style->ID ]->menu_order = 1;
243
-        }
243
+		}
244 244
 
245
-        return $styles;
246
-    }
245
+		return $styles;
246
+	}
247 247
 
248 248
 	public function get_default_style( $styles = null ) {
249
-        if ( ! isset($styles) ) {
249
+		if ( ! isset($styles) ) {
250 250
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
251
-        }
251
+		}
252 252
 
253
-        foreach ( $styles as $style ) {
254
-            if ( $style->menu_order ) {
255
-                return $style;
256
-            }
257
-        }
258
-    }
253
+		foreach ( $styles as $style ) {
254
+			if ( $style->menu_order ) {
255
+				return $style;
256
+			}
257
+		}
258
+	}
259 259
 
260 260
 	public function override_defaults( $settings ) {
261
-	    if ( ! is_array($settings) ) {
262
-	        return $settings;
263
-	    }
264
-
265
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
266
-
267
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
268
-	        $settings['form_desc_size'] = $settings['description_font_size'];
269
-	        $settings['form_desc_color'] = $settings['description_color'];
270
-	        $settings['title_color'] = $settings['label_color'];
271
-	    }
272
-
273
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
274
-	        $settings['section_color'] = $settings['label_color'];
275
-	        $settings['section_border_color'] = $settings['border_color'];
276
-	    }
277
-
278
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
279
-	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
280
-	        $settings['submit_hover_color'] = $settings['submit_text_color'];
281
-	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
282
-
283
-	        $settings['submit_active_bg_color'] = $settings['submit_bg_color'];
284
-	        $settings['submit_active_color'] = $settings['submit_text_color'];
285
-            $settings['submit_active_border_color'] = $settings['submit_border_color'];
286
-	    }
287
-
288
-	    return $settings;
261
+		if ( ! is_array($settings) ) {
262
+			return $settings;
263
+		}
264
+
265
+		$settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
266
+
267
+		if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
268
+			$settings['form_desc_size'] = $settings['description_font_size'];
269
+			$settings['form_desc_color'] = $settings['description_color'];
270
+			$settings['title_color'] = $settings['label_color'];
271
+		}
272
+
273
+		if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
274
+			$settings['section_color'] = $settings['label_color'];
275
+			$settings['section_border_color'] = $settings['border_color'];
276
+		}
277
+
278
+		if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
279
+			$settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
280
+			$settings['submit_hover_color'] = $settings['submit_text_color'];
281
+			$settings['submit_hover_border_color'] = $settings['submit_border_color'];
282
+
283
+			$settings['submit_active_bg_color'] = $settings['submit_bg_color'];
284
+			$settings['submit_active_color'] = $settings['submit_text_color'];
285
+			$settings['submit_active_border_color'] = $settings['submit_border_color'];
286
+		}
287
+
288
+		return $settings;
289 289
 	}
290 290
 
291 291
 	public function get_defaults() {
292
-        return array(
293
-            'theme_css'         => 'ui-lightness',
294
-            'theme_name'        => 'UI Lightness',
292
+		return array(
293
+			'theme_css'         => 'ui-lightness',
294
+			'theme_name'        => 'UI Lightness',
295 295
 
296 296
 			'center_form'		=> '',
297
-            'form_width'        => '100%',
298
-            'form_align'        => 'left',
299
-            'direction'         => is_rtl() ? 'rtl' : 'ltr',
300
-            'fieldset'          => '0px',
301
-            'fieldset_color'    => '000000',
302
-            'fieldset_padding'  => '0 0 15px 0',
303
-            'fieldset_bg_color' => '',
304
-
305
-            'title_size'        => '20px',
306
-            'title_color'       => '444444',
297
+			'form_width'        => '100%',
298
+			'form_align'        => 'left',
299
+			'direction'         => is_rtl() ? 'rtl' : 'ltr',
300
+			'fieldset'          => '0px',
301
+			'fieldset_color'    => '000000',
302
+			'fieldset_padding'  => '0 0 15px 0',
303
+			'fieldset_bg_color' => '',
304
+
305
+			'title_size'        => '20px',
306
+			'title_color'       => '444444',
307 307
 			'title_margin_top'  => '10px',
308 308
 			'title_margin_bottom' => '10px',
309
-            'form_desc_size'    => '14px',
310
-            'form_desc_color'   => '666666',
309
+			'form_desc_size'    => '14px',
310
+			'form_desc_color'   => '666666',
311 311
 			'form_desc_margin_top' => '10px',
312 312
 			'form_desc_margin_bottom' => '25px',
313 313
 
314
-            'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
315
-            'font_size'         => '14px',
316
-            'label_color'       => '444444',
317
-            'weight'            => 'bold',
318
-            'position'          => 'none',
319
-            'align'             => 'left',
320
-            'width'             => '150px',
321
-            'required_color'    => 'B94A48',
322
-            'required_weight'   => 'bold',
323
-            'label_padding'     => '0 0 3px 0',
324
-
325
-            'description_font_size' => '12px',
326
-            'description_color' => '666666',
327
-            'description_weight' => 'normal',
328
-            'description_style' => 'normal',
329
-            'description_align' => 'left',
314
+			'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
315
+			'font_size'         => '14px',
316
+			'label_color'       => '444444',
317
+			'weight'            => 'bold',
318
+			'position'          => 'none',
319
+			'align'             => 'left',
320
+			'width'             => '150px',
321
+			'required_color'    => 'B94A48',
322
+			'required_weight'   => 'bold',
323
+			'label_padding'     => '0 0 3px 0',
324
+
325
+			'description_font_size' => '12px',
326
+			'description_color' => '666666',
327
+			'description_weight' => 'normal',
328
+			'description_style' => 'normal',
329
+			'description_align' => 'left',
330 330
 			'description_margin' => '0',
331 331
 
332
-            'field_font_size'   => '14px',
333
-            'field_height' 		=> '32px',
334
-            'line_height'		=> 'normal',
335
-            'field_width'       => '100%',
336
-            'auto_width'        => false,
337
-            'field_pad'         => '6px 10px',
338
-            'field_margin'      => '20px',
332
+			'field_font_size'   => '14px',
333
+			'field_height' 		=> '32px',
334
+			'line_height'		=> 'normal',
335
+			'field_width'       => '100%',
336
+			'auto_width'        => false,
337
+			'field_pad'         => '6px 10px',
338
+			'field_margin'      => '20px',
339 339
 			'field_weight' => 'normal',
340
-            'text_color'        => '555555',
341
-            //'border_color_hv'   => 'cccccc',
342
-            'border_color'      => 'cccccc',
343
-            'field_border_width' => '1px',
344
-            'field_border_style' => 'solid',
345
-
346
-            'bg_color'          => 'ffffff',
347
-            //'bg_color_hv'       => 'ffffff',
340
+			'text_color'        => '555555',
341
+			//'border_color_hv'   => 'cccccc',
342
+			'border_color'      => 'cccccc',
343
+			'field_border_width' => '1px',
344
+			'field_border_style' => 'solid',
345
+
346
+			'bg_color'          => 'ffffff',
347
+			//'bg_color_hv'       => 'ffffff',
348 348
 			'remove_box_shadow' => '',
349
-            'bg_color_active'   => 'ffffff',
349
+			'bg_color_active'   => 'ffffff',
350 350
 			'border_color_active' => '66afe9',
351 351
 			'remove_box_shadow_active' => '',
352
-            'text_color_error'  => '444444',
353
-            'bg_color_error'    => 'ffffff',
352
+			'text_color_error'  => '444444',
353
+			'bg_color_error'    => 'ffffff',
354 354
 			'border_color_error' => 'B94A48',
355 355
 			'border_width_error' => '1px',
356 356
 			'border_style_error' => 'solid',
357
-            'bg_color_disabled' => 'ffffff',
358
-            'border_color_disabled' => 'E5E5E5',
359
-            'text_color_disabled' => 'A1A1A1',
360
-
361
-            'radio_align'       => 'block',
362
-            'check_align'       => 'block',
363
-            'check_font_size'   => '13px',
364
-            'check_label_color' => '444444',
365
-            'check_weight'      => 'normal',
366
-
367
-            'section_font_size' => '18px',
368
-            'section_color'     => '444444',
369
-            'section_weight'    => 'bold',
370
-            'section_pad'       => '15px 0 3px 0',
371
-            'section_mar_top'   => '15px',
357
+			'bg_color_disabled' => 'ffffff',
358
+			'border_color_disabled' => 'E5E5E5',
359
+			'text_color_disabled' => 'A1A1A1',
360
+
361
+			'radio_align'       => 'block',
362
+			'check_align'       => 'block',
363
+			'check_font_size'   => '13px',
364
+			'check_label_color' => '444444',
365
+			'check_weight'      => 'normal',
366
+
367
+			'section_font_size' => '18px',
368
+			'section_color'     => '444444',
369
+			'section_weight'    => 'bold',
370
+			'section_pad'       => '15px 0 3px 0',
371
+			'section_mar_top'   => '15px',
372 372
 			'section_mar_bottom' => '12px',
373
-            'section_bg_color'  => '',
374
-            'section_border_color' => 'e8e8e8',
375
-            'section_border_width' => '2px',
376
-            'section_border_style' => 'solid',
377
-            'section_border_loc' => '-top',
378
-            'collapse_icon'     => '6',
379
-            'collapse_pos'      => 'after',
380
-            'repeat_icon'       => '1',
381
-
382
-            'submit_style'      => false,
383
-            'submit_font_size'  => '14px',
384
-            'submit_width'      => 'auto',
385
-            'submit_height'     => 'auto',
386
-            'submit_bg_color'   => 'ffffff',
387
-            'submit_border_color' => 'cccccc',
388
-            'submit_border_width' => '1px',
389
-            'submit_text_color' => '444444',
390
-            'submit_weight'     => 'normal',
391
-            'submit_border_radius' => '4px',
392
-            'submit_bg_img'     => '',
393
-            'submit_margin'     => '10px',
394
-            'submit_padding'    => '6px 11px',
395
-            'submit_shadow_color' => 'eeeeee',
396
-            'submit_hover_bg_color' => 'efefef',
397
-            'submit_hover_color' => '444444',
398
-            'submit_hover_border_color' => 'cccccc',
399
-            'submit_active_bg_color' => 'efefef',
400
-            'submit_active_color' => '444444',
401
-            'submit_active_border_color' => 'cccccc',
402
-
403
-            'border_radius'     => '4px',
404
-            'error_bg'          => 'F2DEDE',
405
-            'error_border'      => 'EBCCD1',
406
-            'error_text'        => 'B94A48',
407
-            'error_font_size'   => '14px',
408
-
409
-            'success_bg_color'  => 'DFF0D8',
410
-            'success_border_color' => 'D6E9C6',
411
-            'success_text_color' => '468847',
412
-            'success_font_size' => '14px',
413
-
414
-            'important_style'   => false,
415
-
416
-            'custom_css'        => '',
417
-        );
418
-    }
373
+			'section_bg_color'  => '',
374
+			'section_border_color' => 'e8e8e8',
375
+			'section_border_width' => '2px',
376
+			'section_border_style' => 'solid',
377
+			'section_border_loc' => '-top',
378
+			'collapse_icon'     => '6',
379
+			'collapse_pos'      => 'after',
380
+			'repeat_icon'       => '1',
381
+
382
+			'submit_style'      => false,
383
+			'submit_font_size'  => '14px',
384
+			'submit_width'      => 'auto',
385
+			'submit_height'     => 'auto',
386
+			'submit_bg_color'   => 'ffffff',
387
+			'submit_border_color' => 'cccccc',
388
+			'submit_border_width' => '1px',
389
+			'submit_text_color' => '444444',
390
+			'submit_weight'     => 'normal',
391
+			'submit_border_radius' => '4px',
392
+			'submit_bg_img'     => '',
393
+			'submit_margin'     => '10px',
394
+			'submit_padding'    => '6px 11px',
395
+			'submit_shadow_color' => 'eeeeee',
396
+			'submit_hover_bg_color' => 'efefef',
397
+			'submit_hover_color' => '444444',
398
+			'submit_hover_border_color' => 'cccccc',
399
+			'submit_active_bg_color' => 'efefef',
400
+			'submit_active_color' => '444444',
401
+			'submit_active_border_color' => 'cccccc',
402
+
403
+			'border_radius'     => '4px',
404
+			'error_bg'          => 'F2DEDE',
405
+			'error_border'      => 'EBCCD1',
406
+			'error_text'        => 'B94A48',
407
+			'error_font_size'   => '14px',
408
+
409
+			'success_bg_color'  => 'DFF0D8',
410
+			'success_border_color' => 'D6E9C6',
411
+			'success_text_color' => '468847',
412
+			'success_font_size' => '14px',
413
+
414
+			'important_style'   => false,
415
+
416
+			'custom_css'        => '',
417
+		);
418
+	}
419 419
 
420 420
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
421 421
 		return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 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,10 +67,10 @@  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
 
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
             foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
81 81
                     //if is a color
82
-					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
83
-				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
84
-					$new_instance['post_content'][ $setting ] = 0;
82
+					$new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] );
83
+				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) {
84
+					$new_instance['post_content'][$setting] = 0;
85 85
                 } else if ( $setting == 'font' ) {
86
-                	$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
86
+                	$new_instance['post_content'][$setting] = $this->force_balanced_quotation( $new_instance['post_content'][$setting] );
87 87
                 }
88 88
             }
89 89
 
90
-			$all_instances[ $number ] = $new_instance;
90
+			$all_instances[$number] = $new_instance;
91 91
 
92
-            $action_ids[] = $this->save($new_instance);
92
+            $action_ids[] = $this->save( $new_instance );
93 93
 
94 94
  		}
95 95
 
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
      */
104 104
 	public function save_settings() {
105 105
 		$filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
106
-		update_option( 'frm_last_style_update', date('njGi') );
106
+		update_option( 'frm_last_style_update', date( 'njGi' ) );
107 107
 
108
-        if ( ! is_file($filename) ) {
108
+        if ( ! is_file( $filename ) ) {
109 109
             return;
110 110
         }
111 111
 
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 		$create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) );
115 115
 		$create_file->create_file( $css );
116 116
 
117
-        update_option('frmpro_css', $css);
117
+        update_option( 'frmpro_css', $css );
118 118
 
119 119
 		$this->clear_cache();
120 120
 
121
-        set_transient('frmpro_css', $css);
121
+        set_transient( 'frmpro_css', $css );
122 122
 	}
123 123
 
124 124
 	private function get_css_content( $filename ) {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 
152 152
 	public function destroy( $id ) {
153
-        return wp_delete_post($id);
153
+        return wp_delete_post( $id );
154 154
     }
155 155
 
156 156
     public function get_one() {
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
             return $style;
165 165
         }
166 166
 
167
-        $style = get_post($this->id);
167
+        $style = get_post( $this->id );
168 168
 
169 169
         if ( ! $style ) {
170 170
             return $style;
171 171
         }
172 172
 
173
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
173
+        $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
174 174
 
175 175
         $default_values = $this->get_defaults();
176 176
 
177 177
         // fill default values
178
-        $style->post_content = $this->override_defaults($style->post_content);
179
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
178
+        $style->post_content = $this->override_defaults( $style->post_content );
179
+        $style->post_content = wp_parse_args( $style->post_content, $default_values );
180 180
 
181 181
         return $style;
182 182
     }
@@ -190,21 +190,21 @@  discard block
 block discarded – undo
190 190
 			'order'       => $order,
191 191
         );
192 192
 
193
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
193
+        $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
194 194
 
195
-        if ( empty($temp_styles) ) {
195
+        if ( empty( $temp_styles ) ) {
196 196
             global $wpdb;
197 197
             // make sure there wasn't a conflict with the query
198 198
 			$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' );
199
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
199
+            $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
200 200
 
201
-            if ( empty($temp_styles) ) {
201
+            if ( empty( $temp_styles ) ) {
202 202
                 // create a new style if there are none
203 203
          		$new = $this->get_new();
204 204
          		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
205 205
          		$new->menu_order = 1;
206
-         		$new = $this->save( (array) $new);
207
-         		$this->update('default');
206
+         		$new = $this->save( (array) $new );
207
+         		$this->update( 'default' );
208 208
 
209 209
                 $post_atts['include'] = $new;
210 210
 
@@ -228,25 +228,25 @@  discard block
 block discarded – undo
228 228
                 }
229 229
             }
230 230
 
231
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
231
+            $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
232 232
 
233 233
             // fill default values
234
-            $style->post_content = $this->override_defaults($style->post_content);
235
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
234
+            $style->post_content = $this->override_defaults( $style->post_content );
235
+            $style->post_content = wp_parse_args( $style->post_content, $default_values );
236 236
 
237
-			$styles[ $style->ID ] = $style;
237
+			$styles[$style->ID] = $style;
238 238
         }
239 239
 
240 240
         if ( ! $default_style ) {
241
-            $default_style = reset($styles);
242
-			$styles[ $default_style->ID ]->menu_order = 1;
241
+            $default_style = reset( $styles );
242
+			$styles[$default_style->ID]->menu_order = 1;
243 243
         }
244 244
 
245 245
         return $styles;
246 246
     }
247 247
 
248 248
 	public function get_default_style( $styles = null ) {
249
-        if ( ! isset($styles) ) {
249
+        if ( ! isset( $styles ) ) {
250 250
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
251 251
         }
252 252
 
@@ -258,24 +258,24 @@  discard block
 block discarded – undo
258 258
     }
259 259
 
260 260
 	public function override_defaults( $settings ) {
261
-	    if ( ! is_array($settings) ) {
261
+	    if ( ! is_array( $settings ) ) {
262 262
 	        return $settings;
263 263
 	    }
264 264
 
265
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
265
+	    $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
266 266
 
267
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
267
+	    if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
268 268
 	        $settings['form_desc_size'] = $settings['description_font_size'];
269 269
 	        $settings['form_desc_color'] = $settings['description_color'];
270 270
 	        $settings['title_color'] = $settings['label_color'];
271 271
 	    }
272 272
 
273
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
273
+	    if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) {
274 274
 	        $settings['section_color'] = $settings['label_color'];
275 275
 	        $settings['section_border_color'] = $settings['border_color'];
276 276
 	    }
277 277
 
278
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
278
+	    if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) {
279 279
 	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
280 280
 	        $settings['submit_hover_color'] = $settings['submit_text_color'];
281 281
 	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
Please login to merge, or discard this patch.
classes/models/FrmCreateFile.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 		$this->file_name = $atts['file_name'];
19 19
 		$this->error_message = isset( $atts['error_message'] ) ? $atts['error_message'] : '';
20 20
 		$this->uploads = wp_upload_dir();
21
-		$this->chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
22
-		$this->chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
21
+		$this->chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
22
+		$this->chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
23 23
 	}
24 24
 
25 25
 	public function create_file( $file_content ) {
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 	private function get_ftp_creds( $type ) {
86 86
 		$credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) );
87 87
 
88
-		$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname'];
89
-		$credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username'];
90
-		$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : '';
88
+		$credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname'];
89
+		$credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username'];
90
+		$credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : '';
91 91
 
92 92
 		// Check to see if we are setting the public/private keys for ssh
93
-		$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : '';
94
-		$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : '';
93
+		$credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : '';
94
+		$credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : '';
95 95
 
96 96
 		// Sanitize the hostname, Some people might pass in odd-data:
97 97
 		$credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
Please login to merge, or discard this patch.
classes/views/frm-fields/single-option.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 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 ) ?><?php echo ( $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 ) ?><?php echo ( $field['type'] == 'checkbox' ) ? '[]' : ''; ?>" value="<?php echo esc_attr( $field_val ) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/>
5 5
     <?php } ?>
6
-	<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>
6
+	<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 7
     <span class="frm_option_key field_<?php echo esc_attr( $field['id'] ) ?>_option_key<?php echo esc_attr( $field['separate_value'] ? '' : ' frm_hidden' ); ?>">
8 8
 		<label class="frm-show-click frm_ipe_field_option_key" id="field_key_<?php echo esc_attr( $field['id'] . '-' . $opt_key ) ?>"><?php echo ( $field_val == '' ) ? esc_html__( '(Blank)', 'formidable' ) : $field_val ?></label>
9 9
     </span>
10 10
 </li>
11 11
 <?php
12
-unset($field_val, $opt, $opt_key);
12
+unset( $field_val, $opt, $opt_key );
Please login to merge, or discard this patch.
classes/views/styles/_field-labels.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <div class="field-group field-group-background clearfix frm-first-row">
2 2
 	<label><?php _e( 'Color', 'formidable' ) ?></label>
3
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_color') ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" />
3
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_color' ) ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" />
4 4
 </div>
5 5
 <div class="field-group clearfix frm-first-row">
6 6
 	<label><?php _e( 'Weight', 'formidable' ) ?></label>
7
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('weight') ) ?>" id="frm_weight">
7
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'weight' ) ) ?>" id="frm_weight">
8 8
 		<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
9 9
 		<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
10 10
 		<?php } ?>
@@ -12,45 +12,45 @@  discard block
 block discarded – undo
12 12
 </div>
13 13
 <div class="field-group clearfix frm-first-row">
14 14
 	<label><?php _e( 'Size', 'formidable' ) ?></label>
15
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font_size') ) ?>" id="frm_font_size" value="<?php echo esc_attr($style->post_content['font_size']) ?>"  size="3" />
15
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font_size' ) ) ?>" id="frm_font_size" value="<?php echo esc_attr( $style->post_content['font_size'] ) ?>"  size="3" />
16 16
 </div>
17 17
 
18 18
 <div class="field-group clearfix frm_clear">
19 19
 	<label><?php _e( 'Position', 'formidable' ) ?></label>
20
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('position') ) ?>" id="frm_position">
20
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'position' ) ) ?>" id="frm_position">
21 21
 	    <?php foreach ( array( 'none' => __( 'top', 'formidable' ), 'left' => __( 'left', 'formidable' ), 'right' => __( 'right', 'formidable' ), 'no_label' => __( 'none', 'formidable' ) ) as $pos => $pos_label ) { ?>
22
-	        <option value="<?php echo esc_attr( $pos ) ?>" <?php selected($style->post_content['position'], $pos) ?>><?php echo esc_html( $pos_label ) ?></option>
22
+	        <option value="<?php echo esc_attr( $pos ) ?>" <?php selected( $style->post_content['position'], $pos ) ?>><?php echo esc_html( $pos_label ) ?></option>
23 23
 	    <?php } ?>
24 24
 	</select>
25 25
 </div>
26 26
 
27 27
 <div class="field-group clearfix">
28 28
 	<label><?php _e( 'Align', 'formidable' ) ?></label>
29
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('align') ) ?>" id="frm_align">
30
-		<option value="left" <?php selected($style->post_content['align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option>
31
-		<option value="right" <?php selected($style->post_content['align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option>
29
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'align' ) ) ?>" id="frm_align">
30
+		<option value="left" <?php selected( $style->post_content['align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option>
31
+		<option value="right" <?php selected( $style->post_content['align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option>
32 32
 	</select>
33 33
 </div>
34 34
 
35 35
 <div class="field-group clearfix">
36 36
 	<label><?php _e( 'Width', 'formidable' ) ?></label>
37
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('width') ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" />
37
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'width' ) ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" />
38 38
 </div>
39 39
 
40 40
 <div class="field-group clearfix frm_clear">
41 41
 	<label><?php _e( 'Padding', 'formidable' ) ?></label>
42
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_padding') ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" />
42
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_padding' ) ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" />
43 43
 </div>
44 44
 
45 45
 <div class="clear"></div>
46 46
 <h3><?php _e( 'Required Indicator', 'formidable' ) ?></h3>
47 47
 <div class="field-group field-group-border clearfix after-h3">
48 48
 	<label class="background"><?php _e( 'Color', 'formidable' ) ?></label>
49
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('required_color') ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" />
49
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'required_color' ) ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" />
50 50
 </div>
51 51
 <div class="field-group clearfix after-h3">
52 52
 	<label><?php _e( 'Weight', 'formidable' ) ?></label>
53
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('required_weight') ) ?>" id="frm_required_weight">
53
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'required_weight' ) ) ?>" id="frm_required_weight">
54 54
 		<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
55 55
 		<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['required_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
56 56
 		<?php } ?>
Please login to merge, or discard this patch.
classes/views/styles/_buttons.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <p class="frm_no_top_margin">
2 2
 	<label for="frm_submit_style">
3
-		<input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('submit_style') ) ?>" id="frm_submit_style" <?php checked( $style->post_content['submit_style'], 1 ) ?> value="1" />
3
+		<input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_style' ) ) ?>" id="frm_submit_style" <?php checked( $style->post_content['submit_style'], 1 ) ?> value="1" />
4 4
 		<?php esc_html_e( 'Disable submit button styling', 'formidable' ); ?>
5 5
 		<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Note: If disabled, you may not see the change take effect until you make 2 more styling changes or click "Update Options".', 'formidable' ) ?>"></span>
6 6
 	</label>
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 <div class="posttypediv">
10 10
 	<ul class="posttype-tabs add-menu-item-tabs">
11 11
 		<li <?php echo ( 'default' == $current_tab ? ' class="tabs"' : '' ); ?>>
12
-    		<a href="<?php echo esc_url('?page=formidable-styles&page-tab=default#tabs-panel-button-default') ?>" class="nav-tab-link" data-type="tabs-panel-button-default" ><?php _e( 'Default', 'formidable' ) ?></a>
12
+    		<a href="<?php echo esc_url( '?page=formidable-styles&page-tab=default#tabs-panel-button-default' ) ?>" class="nav-tab-link" data-type="tabs-panel-button-default" ><?php _e( 'Default', 'formidable' ) ?></a>
13 13
     	</li>
14 14
 		<li <?php echo ( 'button-hover' == $current_tab ? ' class="tabs"' : '' ); ?>>
15
-			<a href="<?php echo esc_url('?page=formidable-styles&page-tab=button-hover#page-button-hover') ?>" class="nav-tab-link" data-type="tabs-panel-button-hover" ><?php _e( 'Hover', 'formidable' ) ?></a>
15
+			<a href="<?php echo esc_url( '?page=formidable-styles&page-tab=button-hover#page-button-hover' ) ?>" class="nav-tab-link" data-type="tabs-panel-button-hover" ><?php _e( 'Hover', 'formidable' ) ?></a>
16 16
 		</li>
17 17
 		<li <?php echo ( 'button-click' == $current_tab ? ' class="tabs"' : '' ); ?>>
18 18
 			<a href="?page=formidable-styles&page-tab=button-click#tabs-panel-button-click" class="nav-tab-link" data-type="tabs-panel-button-click"><?php _e( 'Click', 'formidable' ) ?></a>
@@ -24,22 +24,22 @@  discard block
 block discarded – undo
24 24
 	?>">
25 25
 	    <div class="field-group field-group-border clearfix">
26 26
         	<label><?php _e( 'Size', 'formidable' ) ?></label>
27
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_font_size') ) ?>" id="frm_submit_font_size" value="<?php echo esc_attr( $style->post_content['submit_font_size'] ) ?>"  size="3" />
27
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_font_size' ) ) ?>" id="frm_submit_font_size" value="<?php echo esc_attr( $style->post_content['submit_font_size'] ) ?>"  size="3" />
28 28
         </div>
29 29
 
30 30
         <div class="field-group clearfix">
31 31
         	<label><?php _e( 'Width', 'formidable' ) ?></label>
32
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_width') ) ?>" id="frm_submit_width" value="<?php echo esc_attr( $style->post_content['submit_width'] ) ?>"  size="5" />
32
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_width' ) ) ?>" id="frm_submit_width" value="<?php echo esc_attr( $style->post_content['submit_width'] ) ?>"  size="5" />
33 33
         </div>
34 34
 
35 35
         <div class="field-group clearfix">
36 36
         	<label><?php _e( 'Height', 'formidable' ) ?></label>
37
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_height') ) ?>" id="frm_submit_height" value="<?php echo esc_attr( $style->post_content['submit_height'] ) ?>"  size="5" />
37
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_height' ) ) ?>" id="frm_submit_height" value="<?php echo esc_attr( $style->post_content['submit_height'] ) ?>"  size="5" />
38 38
         </div>
39 39
 
40 40
         <div class="field-group clearfix">
41 41
         	<label><?php _e( 'Weight', 'formidable' ) ?></label>
42
-        	<select name="<?php echo esc_attr( $frm_style->get_field_name('submit_weight') ) ?>" id="frm_submit_weight">
42
+        	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_weight' ) ) ?>" id="frm_submit_weight">
43 43
 				<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
44 44
 				<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['submit_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
45 45
 				<?php } ?>
@@ -48,48 +48,48 @@  discard block
 block discarded – undo
48 48
 
49 49
         <div class="field-group clearfix">
50 50
         	<label><?php _e( 'Corners', 'formidable' ) ?></label>
51
-        	<input type="text" value="<?php echo esc_attr( $style->post_content['submit_border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_radius') ) ?>" id="frm_submit_border_radius" size="4"/>
51
+        	<input type="text" value="<?php echo esc_attr( $style->post_content['submit_border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_radius' ) ) ?>" id="frm_submit_border_radius" size="4"/>
52 52
         </div>
53 53
 
54 54
         <div class="field-group field-group-border clearfix">
55 55
         	<label><?php _e( 'BG Color', 'formidable' ) ?></label>
56
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_bg_color') ) ?>" id="frm_submit_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_bg_color'] ) ?>" />
56
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_bg_color' ) ) ?>" id="frm_submit_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_bg_color'] ) ?>" />
57 57
         </div>
58 58
 
59 59
         <div class="field-group clearfix">
60 60
         	<label><?php _e( 'Text', 'formidable' ) ?></label>
61
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_text_color') ) ?>" id="frm_submit_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_text_color'] ) ?>" />
61
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_text_color' ) ) ?>" id="frm_submit_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_text_color'] ) ?>" />
62 62
         </div>
63 63
 
64 64
         <div class="field-group field-group-border clearfix">
65 65
         	<label><?php _e( 'Border', 'formidable' ) ?></label>
66
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_color') ) ?>" id="frm_submit_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_border_color'] ) ?>" />
66
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_color' ) ) ?>" id="frm_submit_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_border_color'] ) ?>" />
67 67
         </div>
68 68
 
69 69
         <div class="field-group clearfix">
70 70
         	<label><?php _e( 'Thickness', 'formidable' ) ?></label>
71
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_width') ) ?>" id="frm_submit_border_width" value="<?php echo esc_attr( $style->post_content['submit_border_width'] ) ?>" size="4" />
71
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_width' ) ) ?>" id="frm_submit_border_width" value="<?php echo esc_attr( $style->post_content['submit_border_width'] ) ?>" size="4" />
72 72
         </div>
73 73
 
74 74
         <div class="field-group clearfix">
75 75
         	<label><?php _e( 'Shadow', 'formidable' ) ?></label>
76
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_shadow_color') ) ?>" id="frm_submit_shadow_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_shadow_color'] ) ?>" />
76
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_shadow_color' ) ) ?>" id="frm_submit_shadow_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_shadow_color'] ) ?>" />
77 77
         </div>
78 78
 
79 79
         <div class="clear"></div>
80 80
         <div class="field-group field-group-border frm-full">
81 81
         	<label><?php _e( 'BG Image', 'formidable' ) ?></label>
82
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_bg_img') ) ?>" id="frm_submit_bg_img" value="<?php echo esc_attr( $style->post_content['submit_bg_img'] ) ?>"  />
82
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_bg_img' ) ) ?>" id="frm_submit_bg_img" value="<?php echo esc_attr( $style->post_content['submit_bg_img'] ) ?>"  />
83 83
         </div>
84 84
 
85 85
         <div class="field-group field-group-border clearfix">
86 86
         	<label><?php _e( 'Margin', 'formidable' ) ?></label>
87
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_margin') ) ?>" id="frm_submit_margin" value="<?php echo esc_attr( $style->post_content['submit_margin'] ) ?>" size="6" />
87
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_margin' ) ) ?>" id="frm_submit_margin" value="<?php echo esc_attr( $style->post_content['submit_margin'] ) ?>" size="6" />
88 88
         </div>
89 89
 
90 90
         <div class="field-group clearfix">
91 91
         	<label><?php _e( 'Padding', 'formidable' ) ?></label>
92
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_padding') ) ?>" id="frm_submit_padding" value="<?php echo esc_attr( $style->post_content['submit_padding'] ) ?>" size="6" />
92
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_padding' ) ) ?>" id="frm_submit_padding" value="<?php echo esc_attr( $style->post_content['submit_padding'] ) ?>" size="6" />
93 93
         </div>
94 94
         <div class="clear"></div>
95 95
 	</div><!-- /.tabs-panel -->
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
 	?>">
100 100
 	    <div class="field-group clearfix">
101 101
         	<label><?php _e( 'BG Color', 'formidable' ) ?></label>
102
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_bg_color') ) ?>" id="frm_submit_hover_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_bg_color'] ) ?>" />
102
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_bg_color' ) ) ?>" id="frm_submit_hover_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_bg_color'] ) ?>" />
103 103
         </div>
104 104
 
105 105
         <div class="field-group clearfix">
106 106
     	    <label><?php _e( 'Text', 'formidable' ) ?></label>
107
-    	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_color') ) ?>" id="frm_submit_hover_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_color'] ) ?>" />
107
+    	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_color' ) ) ?>" id="frm_submit_hover_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_color'] ) ?>" />
108 108
         </div>
109 109
 
110 110
         <div class="field-group clearfix">
111 111
             <label><?php _e( 'Border', 'formidable' ) ?></label>
112
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_border_color') ) ?>" id="frm_submit_hover_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_border_color'] ) ?>" />
112
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_border_color' ) ) ?>" id="frm_submit_hover_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_border_color'] ) ?>" />
113 113
         </div>
114 114
 
115 115
 	    <div class="clear"></div>
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
 	?>">
121 121
 	    <div class="field-group clearfix">
122 122
         	<label><?php _e( 'BG Color', 'formidable' ) ?></label>
123
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_bg_color') ) ?>" id="frm_submit_active_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_bg_color'] ) ?>" />
123
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_bg_color' ) ) ?>" id="frm_submit_active_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_bg_color'] ) ?>" />
124 124
         </div>
125 125
 
126 126
         <div class="field-group clearfix">
127 127
     	    <label><?php _e( 'Text', 'formidable' ) ?></label>
128
-    	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_color') ) ?>" id="frm_submit_active_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_color'] ) ?>" />
128
+    	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_color' ) ) ?>" id="frm_submit_active_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_color'] ) ?>" />
129 129
         </div>
130 130
 
131 131
         <div class="field-group clearfix">
132 132
             <label><?php _e( 'Border', 'formidable' ) ?></label>
133
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_border_color') ) ?>" id="frm_submit_active_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_border_color'] ) ?>" />
133
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_border_color' ) ) ?>" id="frm_submit_active_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_border_color'] ) ?>" />
134 134
         </div>
135 135
 
136 136
 	    <div class="clear"></div>
Please login to merge, or discard this patch.
classes/controllers/FrmSettingsController.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -2,26 +2,26 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmSettingsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		// Make sure admins can see the menu items
7 7
 		FrmAppHelper::force_capability( 'frm_change_settings' );
8 8
 
9
-        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
-    }
9
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
+	}
11 11
 
12
-    public static function license_box() {
12
+	public static function license_box() {
13 13
 		$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14
-        include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
-    }
14
+		include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
+	}
16 16
 
17
-    public static function display_form( $errors = array(), $message = '' ) {
18
-        global $frm_vars;
17
+	public static function display_form( $errors = array(), $message = '' ) {
18
+		global $frm_vars;
19 19
 
20
-        $frm_settings = FrmAppHelper::get_settings();
21
-        $frm_roles = FrmAppHelper::frm_capabilities();
20
+		$frm_settings = FrmAppHelper::get_settings();
21
+		$frm_roles = FrmAppHelper::frm_capabilities();
22 22
 
23
-        $uploads = wp_upload_dir();
24
-        $target_path = $uploads['basedir'] . '/formidable/css';
23
+		$uploads = wp_upload_dir();
24
+		$target_path = $uploads['basedir'] . '/formidable/css';
25 25
 
26 26
 		$sections = array();
27 27
 		if ( apply_filters( 'frm_include_addon_page', false ) ) {
@@ -30,53 +30,53 @@  discard block
 block discarded – undo
30 30
 				'name' => __( 'Plugin Licenses', 'formidable' ),
31 31
 			);
32 32
 		}
33
-        $sections = apply_filters( 'frm_add_settings_section', $sections );
33
+		$sections = apply_filters( 'frm_add_settings_section', $sections );
34 34
 
35
-        $captcha_lang = FrmAppHelper::locales( 'captcha' );
35
+		$captcha_lang = FrmAppHelper::locales( 'captcha' );
36 36
 
37
-        require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
38
-    }
37
+		require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
38
+	}
39 39
 
40
-    public static function process_form( $stop_load = false ) {
41
-        global $frm_vars;
40
+	public static function process_form( $stop_load = false ) {
41
+		global $frm_vars;
42 42
 
43
-        $frm_settings = FrmAppHelper::get_settings();
43
+		$frm_settings = FrmAppHelper::get_settings();
44 44
 
45 45
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
46 46
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
47
-            wp_die( $frm_settings->admin_permission );
48
-        }
47
+			wp_die( $frm_settings->admin_permission );
48
+		}
49 49
 
50
-        $errors = array();
51
-        $message = '';
50
+		$errors = array();
51
+		$message = '';
52 52
 
53
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
54
-            //$errors = $frm_settings->validate($_POST,array());
55
-            $frm_settings->update( stripslashes_deep( $_POST ) );
53
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
54
+			//$errors = $frm_settings->validate($_POST,array());
55
+			$frm_settings->update( stripslashes_deep( $_POST ) );
56 56
 
57
-            if ( empty( $errors ) ) {
58
-                $frm_settings->store();
59
-                $message = __( 'Settings Saved', 'formidable' );
60
-            }
61
-        } else {
62
-            $message = __( 'Settings Saved', 'formidable' );
63
-        }
57
+			if ( empty( $errors ) ) {
58
+				$frm_settings->store();
59
+				$message = __( 'Settings Saved', 'formidable' );
60
+			}
61
+		} else {
62
+			$message = __( 'Settings Saved', 'formidable' );
63
+		}
64 64
 
65 65
 		if ( $stop_load == 'stop_load' ) {
66
-            $frm_vars['settings_routed'] = true;
67
-            return;
68
-        }
66
+			$frm_vars['settings_routed'] = true;
67
+			return;
68
+		}
69 69
 
70
-        self::display_form( $errors, $message );
71
-    }
70
+		self::display_form( $errors, $message );
71
+	}
72 72
 
73
-    public static function route( $stop_load = false ) {
74
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
73
+	public static function route( $stop_load = false ) {
74
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
75 75
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
76
-        if ( $action == 'process-form' ) {
76
+		if ( $action == 'process-form' ) {
77 77
 			self::process_form( $stop_load );
78
-        } else if ( $stop_load != 'stop_load' ) {
78
+		} else if ( $stop_load != 'stop_load' ) {
79 79
 			self::display_form();
80
-        }
81
-    }
80
+		}
81
+	}
82 82
 }
Please login to merge, or discard this patch.
classes/views/styles/_field-description.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <div class="field-group field-group-background clearfix frm-first-row">
2 2
 	<label><?php _e( 'Color', 'formidable' ) ?></label>
3
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_color') ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" />
3
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_color' ) ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" />
4 4
 </div>
5 5
 <div class="field-group clearfix frm-first-row">
6 6
 	<label><?php _e( 'Weight', 'formidable' ) ?></label>
7
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_weight') ) ?>" id="frm_description_weight">
7
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_weight' ) ) ?>" id="frm_description_weight">
8 8
 		<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
9 9
 		<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['description_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
10 10
 		<?php } ?>
@@ -12,25 +12,25 @@  discard block
 block discarded – undo
12 12
 </div>
13 13
 <div class="field-group clearfix frm-first-row">
14 14
 	<label><?php _e( 'Style', 'formidable' ) ?></label>
15
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_style') ) ?>" id="frm_description_style">
16
-		<option value="normal" <?php selected($style->post_content['description_style'], 'normal') ?>><?php _e( 'normal', 'formidable' ) ?></option>
17
-		<option value="italic" <?php selected($style->post_content['description_style'], 'italic') ?>><?php _e( 'italic', 'formidable' ) ?></option>
15
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_style' ) ) ?>" id="frm_description_style">
16
+		<option value="normal" <?php selected( $style->post_content['description_style'], 'normal' ) ?>><?php _e( 'normal', 'formidable' ) ?></option>
17
+		<option value="italic" <?php selected( $style->post_content['description_style'], 'italic' ) ?>><?php _e( 'italic', 'formidable' ) ?></option>
18 18
 	</select>
19 19
 </div>
20 20
 
21 21
 <div class="field-group clearfix">
22 22
 	<label><?php _e( 'Size', 'formidable' ) ?></label>
23
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_font_size') ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>"  size="3" />
23
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_font_size' ) ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>"  size="3" />
24 24
 </div>
25 25
 <div class="field-group clearfix">
26 26
 	<label><?php _e( 'Align', 'formidable' ) ?></label>
27
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_align') ) ?>" id="frm_description_align">
28
-		<option value="left" <?php selected($style->post_content['description_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option>
29
-		<option value="right" <?php selected($style->post_content['description_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option>
27
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_align' ) ) ?>" id="frm_description_align">
28
+		<option value="left" <?php selected( $style->post_content['description_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option>
29
+		<option value="right" <?php selected( $style->post_content['description_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option>
30 30
 	</select>
31 31
 </div>
32 32
 <div class="field-group clearfix">
33 33
 	<label><?php _e( 'Margin', 'formidable' ) ?></label>
34
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_margin') ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>"  size="3" />
34
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_margin' ) ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>"  size="3" />
35 35
 </div>
36 36
 <div class="clear"></div>
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 3 patches
Spacing   +209 added lines, -209 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 ) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	public static function get_affiliate() {
69
-		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') );
69
+		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) );
70 70
 		$affiliate_id = strtolower( $affiliate_id );
71 71
 		$allowed_affiliates = array( 'mojo' );
72 72
 		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public static function get_settings() {
87 87
         global $frm_settings;
88
-        if ( empty($frm_settings) ) {
88
+        if ( empty( $frm_settings ) ) {
89 89
             $frm_settings = new FrmSettings();
90 90
         }
91 91
         return $frm_settings;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     }
107 107
 
108 108
     public static function pro_is_installed() {
109
-        return apply_filters('frm_pro_installed', false);
109
+        return apply_filters( 'frm_pro_installed', false );
110 110
     }
111 111
 
112 112
     /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @return boolean
151 151
      */
152 152
     public static function doing_ajax() {
153
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
153
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
154 154
     }
155 155
 
156 156
 	/**
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @return boolean
171 171
      */
172 172
     public static function is_admin() {
173
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
173
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
174 174
     }
175 175
 
176 176
     /**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      * @return string
197 197
      */
198 198
 	public static function get_server_value( $value ) {
199
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
199
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
200 200
     }
201 201
 
202 202
     /**
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
212 212
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
213 213
         ) as $key ) {
214
-            if ( ! isset( $_SERVER[ $key ] ) ) {
214
+            if ( ! isset( $_SERVER[$key] ) ) {
215 215
                 continue;
216 216
             }
217 217
 
218
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
219
-                $ip = trim($ip); // just to be safe
218
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
219
+                $ip = trim( $ip ); // just to be safe
220 220
 
221
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
221
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
222 222
                     return $ip;
223 223
                 }
224 224
             }
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
     }
229 229
 
230 230
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
231
-        if ( strpos($param, '[') ) {
232
-            $params = explode('[', $param);
231
+        if ( strpos( $param, '[' ) ) {
232
+            $params = explode( '[', $param );
233 233
             $param = $params[0];
234 234
         }
235 235
 
236 236
 		if ( $src == 'get' ) {
237
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
238
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
239
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
237
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
238
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
239
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
240 240
             }
241 241
 			self::sanitize_value( $sanitize, $value );
242 242
 		} else {
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 
246 246
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
247 247
             foreach ( $params as $k => $p ) {
248
-                if ( ! $k || ! is_array($value) ) {
248
+                if ( ! $k || ! is_array( $value ) ) {
249 249
                     continue;
250 250
                 }
251 251
 
252
-                $p = trim($p, ']');
253
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
252
+                $p = trim( $p, ']' );
253
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
254 254
             }
255 255
         }
256 256
 
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
 
293 293
 		$value = $args['default'];
294 294
 		if ( $args['type'] == 'get' ) {
295
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
296
-				$value = $_GET[ $args['param'] ];
295
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
296
+				$value = $_GET[$args['param']];
297 297
 			}
298 298
 		} else if ( $args['type'] == 'post' ) {
299
-			if ( isset( $_POST[ $args['param'] ] ) ) {
300
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
299
+			if ( isset( $_POST[$args['param']] ) ) {
300
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
301 301
 			}
302 302
 		} else {
303
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
304
-				$value = $_REQUEST[ $args['param'] ];
303
+			if ( isset( $_REQUEST[$args['param']] ) ) {
304
+				$value = $_REQUEST[$args['param']];
305 305
 			}
306 306
 		}
307 307
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			if ( is_array( $value ) ) {
330 330
 				$temp_values = $value;
331 331
 				foreach ( $temp_values as $k => $v ) {
332
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
332
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
333 333
 				}
334 334
 			} else {
335 335
 				$value = call_user_func( $sanitize, $value );
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
     public static function sanitize_request( $sanitize_method, &$values ) {
341 341
         $temp_values = $values;
342 342
         foreach ( $temp_values as $k => $val ) {
343
-            if ( isset( $sanitize_method[ $k ] ) ) {
344
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
343
+            if ( isset( $sanitize_method[$k] ) ) {
344
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
345 345
             }
346 346
         }
347 347
     }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	public static function sanitize_array( &$values ) {
350 350
 		$temp_values = $values;
351 351
 		foreach ( $temp_values as $k => $val ) {
352
-			$values[ $k ] = wp_kses_post( $val );
352
+			$values[$k] = wp_kses_post( $val );
353 353
 		}
354 354
 	}
355 355
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 		$allowed_html = array();
371 371
 		foreach ( $allowed as $a ) {
372
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
372
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
373 373
 		}
374 374
 
375 375
 		return wp_kses( $value, $allowed_html );
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      * @since 2.0
381 381
      */
382 382
     public static function remove_get_action() {
383
-        if ( ! isset($_GET) ) {
383
+        if ( ! isset( $_GET ) ) {
384 384
             return;
385 385
         }
386 386
 
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
         }
403 403
 
404 404
         global $wp_query;
405
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
406
-            $value = $wp_query->query_vars[ $param ];
405
+        if ( isset( $wp_query->query_vars[$param] ) ) {
406
+            $value = $wp_query->query_vars[$param];
407 407
         }
408 408
 
409 409
         return $value;
@@ -432,16 +432,16 @@  discard block
 block discarded – undo
432 432
      * @return mixed $results The cache or query results
433 433
      */
434 434
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
435
-        $results = wp_cache_get($cache_key, $group);
436
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
435
+        $results = wp_cache_get( $cache_key, $group );
436
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
437 437
             return $results;
438 438
         }
439 439
 
440 440
         if ( 'get_posts' == $type ) {
441
-            $results = get_posts($query);
441
+            $results = get_posts( $query );
442 442
         } else {
443 443
             global $wpdb;
444
-            $results = $wpdb->{$type}($query);
444
+            $results = $wpdb->{$type}( $query );
445 445
         }
446 446
 
447 447
 		if ( ! self::prevent_caching() ) {
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
         }
466 466
 
467 467
         // then check the transient
468
-        $results = get_transient($cache_key);
468
+        $results = get_transient( $cache_key );
469 469
         if ( $results ) {
470
-            wp_cache_set($cache_key, $results);
470
+            wp_cache_set( $cache_key, $results );
471 471
         }
472 472
 
473 473
         return $results;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      * @param string $cache_key
479 479
      */
480 480
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
481
-		delete_transient($cache_key);
481
+		delete_transient( $cache_key );
482 482
 		wp_cache_delete( $cache_key, $group );
483 483
 	}
484 484
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     	global $wp_object_cache;
495 495
 
496 496
 		if ( is_callable( array( $wp_object_cache, '__get' ) ) ) {
497
-			$group_cache = $wp_object_cache->__get('cache');
497
+			$group_cache = $wp_object_cache->__get( 'cache' );
498 498
 		} elseif ( is_callable( array( $wp_object_cache, 'redis_status' ) ) && $wp_object_cache->redis_status() ) {
499 499
 			// check if the object cache is overridden by Redis
500 500
 			$wp_object_cache->flush();
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 			$group_cache = $wp_object_cache->cache;
505 505
 		}
506 506
 
507
-		if ( isset( $group_cache[ $group ] ) ) {
508
-			foreach ( $group_cache[ $group ] as $k => $v ) {
507
+		if ( isset( $group_cache[$group] ) ) {
508
+			foreach ( $group_cache[$group] as $k => $v ) {
509 509
 				wp_cache_delete( $k, $group );
510 510
 			}
511 511
 			return true;
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
     }
536 536
 
537 537
     public static function get_pages() {
538
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
538
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
539 539
     }
540 540
 
541 541
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
542 542
         $pages = self::get_pages();
543 543
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
544 544
     ?>
545
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
545
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
546 546
             <option value=""> </option>
547 547
             <?php foreach ( $pages as $page ) { ?>
548
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
548
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
549 549
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
550 550
 				</option>
551 551
             <?php } ?>
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
     }
555 555
 
556 556
 	public static function post_edit_link( $post_id ) {
557
-        $post = get_post($post_id);
557
+        $post = get_post( $post_id );
558 558
         if ( $post ) {
559 559
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
560 560
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -564,17 +564,17 @@  discard block
 block discarded – undo
564 564
 
565 565
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
566 566
     ?>
567
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
567
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
568 568
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
569 569
             ?> class="frm_multiselect">
570
-            <?php self::roles_options($capability); ?>
570
+            <?php self::roles_options( $capability ); ?>
571 571
         </select>
572 572
     <?php
573 573
     }
574 574
 
575 575
 	public static function roles_options( $capability ) {
576 576
         global $frm_vars;
577
-        if ( isset($frm_vars['editable_roles']) ) {
577
+        if ( isset( $frm_vars['editable_roles'] ) ) {
578 578
             $editable_roles = $frm_vars['editable_roles'];
579 579
         } else {
580 580
             $editable_roles = get_editable_roles();
@@ -582,10 +582,10 @@  discard block
 block discarded – undo
582 582
         }
583 583
 
584 584
         foreach ( $editable_roles as $role => $details ) {
585
-            $name = translate_user_role($details['name'] ); ?>
586
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
585
+            $name = translate_user_role( $details['name'] ); ?>
586
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
587 587
 <?php
588
-            unset($role, $details);
588
+            unset( $role, $details );
589 589
         }
590 590
     }
591 591
 
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
     public static function maybe_add_permissions() {
642 642
 		self::force_capability( 'frm_view_entries' );
643 643
 
644
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
644
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
645 645
             return;
646 646
         }
647 647
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         $frm_roles = self::frm_capabilities();
651 651
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
652 652
 			$user->add_cap( $frm_role );
653
-            unset($frm_role, $frm_role_description);
653
+            unset( $frm_role, $frm_role_description );
654 654
         }
655 655
     }
656 656
 
@@ -675,12 +675,12 @@  discard block
 block discarded – undo
675 675
      * @param string $permission
676 676
      */
677 677
 	public static function permission_check( $permission, $show_message = 'show' ) {
678
-        $permission_error = self::permission_nonce_error($permission);
678
+        $permission_error = self::permission_nonce_error( $permission );
679 679
         if ( $permission_error !== false ) {
680 680
             if ( 'hide' == $show_message ) {
681 681
                 $permission_error = '';
682 682
             }
683
-            wp_die($permission_error);
683
+            wp_die( $permission_error );
684 684
         }
685 685
     }
686 686
 
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 		}
698 698
 
699 699
 		$error = false;
700
-        if ( empty($nonce_name) ) {
700
+        if ( empty( $nonce_name ) ) {
701 701
             return $error;
702 702
         }
703 703
 
704
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
704
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
705 705
             $frm_settings = self::get_settings();
706 706
             $error = $frm_settings->admin_permission;
707 707
         }
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 			} else {
782 782
 				foreach ( $value as $k => $v ) {
783 783
 					if ( ! is_array( $v ) ) {
784
-						$value[ $k ] = call_user_func( $original_function, $v );
784
+						$value[$k] = call_user_func( $original_function, $v );
785 785
 					}
786 786
 				}
787 787
 			}
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
 	public static function array_flatten( $array, $keys = 'keep' ) {
803 803
         $return = array();
804 804
         foreach ( $array as $key => $value ) {
805
-            if ( is_array($value) ) {
805
+            if ( is_array( $value ) ) {
806 806
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
807 807
             } else {
808 808
 				if ( $keys == 'keep' ) {
809
-					$return[ $key ] = $value;
809
+					$return[$key] = $value;
810 810
 				} else {
811 811
 					$return[] = $value;
812 812
 				}
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
      * @since 2.0
830 830
      */
831 831
 	public static function use_wpautop( $content ) {
832
-        if ( apply_filters('frm_use_wpautop', true) ) {
833
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
832
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
833
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
834 834
         }
835 835
         return $content;
836 836
     }
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
      * @return string The base Google APIS url for the current version of jQuery UI
849 849
      */
850 850
     public static function jquery_ui_base_url() {
851
-		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
852
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
851
+		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
852
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
853 853
         return $url;
854 854
     }
855 855
 
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
 
865 865
         $ver = 0;
866 866
 
867
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
867
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
868 868
             return $ver;
869 869
         }
870 870
 
871
-        $query = $wp_scripts->registered[ $handle ];
871
+        $query = $wp_scripts->registered[$handle];
872 872
     	if ( is_object( $query ) ) {
873 873
     	    $ver = $query->ver;
874 874
     	}
@@ -881,36 +881,36 @@  discard block
 block discarded – undo
881 881
     }
882 882
 
883 883
 	public static function get_user_id_param( $user_id ) {
884
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
884
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
885 885
             return $user_id;
886 886
         }
887 887
 
888 888
 		if ( $user_id == 'current' ) {
889 889
 			$user_id = get_current_user_id();
890 890
 		} else {
891
-            if ( is_email($user_id) ) {
892
-                $user = get_user_by('email', $user_id);
891
+            if ( is_email( $user_id ) ) {
892
+                $user = get_user_by( 'email', $user_id );
893 893
             } else {
894
-                $user = get_user_by('login', $user_id);
894
+                $user = get_user_by( 'login', $user_id );
895 895
             }
896 896
 
897 897
             if ( $user ) {
898 898
                 $user_id = $user->ID;
899 899
             }
900
-            unset($user);
900
+            unset( $user );
901 901
         }
902 902
 
903 903
         return $user_id;
904 904
     }
905 905
 
906 906
 	public static function get_file_contents( $filename, $atts = array() ) {
907
-        if ( ! is_file($filename) ) {
907
+        if ( ! is_file( $filename ) ) {
908 908
             return false;
909 909
         }
910 910
 
911
-        extract($atts);
911
+        extract( $atts );
912 912
         ob_start();
913
-        include($filename);
913
+        include( $filename );
914 914
         $contents = ob_get_contents();
915 915
         ob_end_clean();
916 916
         return $contents;
@@ -926,28 +926,28 @@  discard block
 block discarded – undo
926 926
         $key = '';
927 927
 
928 928
         if ( ! empty( $name ) ) {
929
-            $key = sanitize_key($name);
929
+            $key = sanitize_key( $name );
930 930
         }
931 931
 
932 932
 		if ( empty( $key ) ) {
933
-            $max_slug_value = pow(36, $num_chars);
933
+            $max_slug_value = pow( 36, $num_chars );
934 934
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
935
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
935
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
936 936
         }
937 937
 
938
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
938
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
939 939
 			$key = $key . 'a';
940 940
         }
941 941
 
942 942
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
943 943
 
944
-        if ( $key_check || is_numeric($key_check) ) {
944
+        if ( $key_check || is_numeric( $key_check ) ) {
945 945
             $suffix = 2;
946 946
 			do {
947 947
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
948 948
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
949
-				$suffix++;
950
-			} while ($key_check || is_numeric($key_check));
949
+				$suffix ++;
950
+			} while ( $key_check || is_numeric( $key_check ) );
951 951
 			$key = $alt_post_name;
952 952
         }
953 953
         return $key;
@@ -963,32 +963,32 @@  discard block
 block discarded – undo
963 963
             return false;
964 964
         }
965 965
 
966
-        if ( empty($post_values) ) {
967
-            $post_values = stripslashes_deep($_POST);
966
+        if ( empty( $post_values ) ) {
967
+            $post_values = stripslashes_deep( $_POST );
968 968
         }
969 969
 
970 970
 		$values = array( 'id' => $record->id, 'fields' => array() );
971 971
 
972 972
 		foreach ( array( 'name', 'description' ) as $var ) {
973
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
974
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
975
-            unset($var, $default_val);
973
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
974
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
975
+            unset( $var, $default_val );
976 976
         }
977 977
 
978
-        $values['description'] = self::use_wpautop($values['description']);
978
+        $values['description'] = self::use_wpautop( $values['description'] );
979 979
         $frm_settings = self::get_settings();
980
-        $is_form_builder = self::is_admin_page('formidable' );
980
+        $is_form_builder = self::is_admin_page( 'formidable' );
981 981
 
982 982
         foreach ( (array) $fields as $field ) {
983 983
             // Make sure to filter default values (for placeholder text), but not on the form builder page
984 984
             if ( ! $is_form_builder ) {
985
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
985
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
986 986
             }
987 987
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
988
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
988
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
989 989
         }
990 990
 
991
-        self::fill_form_opts($record, $table, $post_values, $values);
991
+        self::fill_form_opts( $record, $table, $post_values, $values );
992 992
 
993 993
         if ( $table == 'entries' ) {
994 994
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
         if ( $args['default'] ) {
1006 1006
             $meta_value = $field->default_value;
1007 1007
         } else {
1008
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1009
-                if ( ! isset($field->field_options['custom_field']) ) {
1008
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1009
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1010 1010
                     $field->field_options['custom_field'] = '';
1011 1011
                 }
1012 1012
 				$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 ) );
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
             }
1016 1016
         }
1017 1017
 
1018
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1019
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1018
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1019
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1020 1020
 
1021 1021
         $field_array = array(
1022 1022
             'id'            => $field->id,
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
             'default_value' => $field->default_value,
1025 1025
             'name'          => $field->name,
1026 1026
             'description'   => $field->description,
1027
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1027
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1028 1028
             'options'       => $field->options,
1029 1029
             'required'      => $field->required,
1030 1030
             'field_key'     => $field->field_key,
@@ -1034,40 +1034,40 @@  discard block
 block discarded – undo
1034 1034
         );
1035 1035
 
1036 1036
         $args['field_type'] = $field_type;
1037
-        self::fill_field_opts($field, $field_array, $args);
1037
+        self::fill_field_opts( $field, $field_array, $args );
1038 1038
 		// Track the original field's type
1039 1039
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1040 1040
 
1041 1041
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1042 1042
 
1043
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1043
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1044 1044
             $field_array['unique_msg'] = '';
1045 1045
         }
1046 1046
 
1047 1047
         $field_array = array_merge( $field->field_options, $field_array );
1048 1048
 
1049
-        $values['fields'][ $field->id ] = $field_array;
1049
+        $values['fields'][$field->id] = $field_array;
1050 1050
     }
1051 1051
 
1052 1052
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1053 1053
         $post_values = $args['post_values'];
1054
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1054
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1055 1055
 
1056 1056
         foreach ( $opt_defaults as $opt => $default_opt ) {
1057
-			$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 );
1058
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1059
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1060
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1057
+			$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 );
1058
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1059
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1060
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1061 1061
                 if ( $args['field_type'] == 'captcha' ) {
1062
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1062
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1063 1063
                 } else {
1064
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1064
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1065 1065
                 }
1066 1066
             }
1067 1067
         }
1068 1068
 
1069 1069
         if ( $field_array['custom_html'] == '' ) {
1070
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1070
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1071 1071
         }
1072 1072
     }
1073 1073
 
@@ -1086,18 +1086,18 @@  discard block
 block discarded – undo
1086 1086
             return;
1087 1087
         }
1088 1088
 
1089
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1089
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1090 1090
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1091 1091
 
1092
-        if ( ! is_array($form->options) ) {
1092
+        if ( ! is_array( $form->options ) ) {
1093 1093
             return;
1094 1094
         }
1095 1095
 
1096 1096
         foreach ( $form->options as $opt => $value ) {
1097
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1097
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1098 1098
         }
1099 1099
 
1100
-        self::fill_form_defaults($post_values, $values);
1100
+        self::fill_form_defaults( $post_values, $values );
1101 1101
     }
1102 1102
 
1103 1103
     /**
@@ -1107,23 +1107,23 @@  discard block
 block discarded – undo
1107 1107
         $form_defaults = FrmFormsHelper::get_default_opts();
1108 1108
 
1109 1109
         foreach ( $form_defaults as $opt => $default ) {
1110
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1111
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1110
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1111
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1112 1112
             }
1113 1113
 
1114
-            unset($opt, $defaut);
1114
+            unset( $opt, $defaut );
1115 1115
         }
1116 1116
 
1117
-        if ( ! isset($values['custom_style']) ) {
1117
+        if ( ! isset( $values['custom_style'] ) ) {
1118 1118
             $frm_settings = self::get_settings();
1119 1119
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1120 1120
         }
1121 1121
 
1122 1122
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1123
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1124
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1123
+			if ( ! isset( $values[$h . '_html'] ) ) {
1124
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1125 1125
             }
1126
-            unset($h);
1126
+            unset( $h );
1127 1127
         }
1128 1128
     }
1129 1129
 
@@ -1139,9 +1139,9 @@  discard block
 block discarded – undo
1139 1139
         }
1140 1140
     ?>
1141 1141
 <li>
1142
-    <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>
1143
-    <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>
1144
-    <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>
1142
+    <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>
1143
+    <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>
1144
+    <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>
1145 1145
 </li>
1146 1146
     <?php
1147 1147
     }
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
             return '';
1160 1160
         } else if ( $length <= 10 ) {
1161 1161
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1162
-            return $sub . (($length < $original_len) ? $continue : '');
1162
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1163 1163
         }
1164 1164
 
1165 1165
         $sub = '';
@@ -1168,23 +1168,23 @@  discard block
 block discarded – undo
1168 1168
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1169 1169
 
1170 1170
 		foreach ( $words as $word ) {
1171
-            $part = (($sub != '') ? ' ' : '') . $word;
1171
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1172 1172
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1173
-            if ( $total_len > $length && str_word_count($sub) ) {
1173
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1174 1174
                 break;
1175 1175
             }
1176 1176
 
1177 1177
             $sub .= $part;
1178 1178
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1179 1179
 
1180
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1180
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1181 1181
                 break;
1182 1182
             }
1183 1183
 
1184
-            unset($total_len, $word);
1184
+            unset( $total_len, $word );
1185 1185
         }
1186 1186
 
1187
-        return $sub . (($len < $original_len) ? $continue : '');
1187
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1188 1188
     }
1189 1189
 
1190 1190
 	public static function mb_function( $function_names, $args ) {
@@ -1197,17 +1197,17 @@  discard block
 block discarded – undo
1197 1197
 	}
1198 1198
 
1199 1199
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1200
-        if ( empty($date) ) {
1200
+        if ( empty( $date ) ) {
1201 1201
             return $date;
1202 1202
         }
1203 1203
 
1204
-        if ( empty($date_format) ) {
1205
-            $date_format = get_option('date_format');
1204
+        if ( empty( $date_format ) ) {
1205
+            $date_format = get_option( 'date_format' );
1206 1206
         }
1207 1207
 
1208
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1208
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1209 1209
             $frmpro_settings = new FrmProSettings();
1210
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1210
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1211 1211
         }
1212 1212
 
1213 1213
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 
1223 1223
 	private static function add_time_to_date( $time_format, $date ) {
1224 1224
 		if ( empty( $time_format ) ) {
1225
-			$time_format = get_option('time_format');
1225
+			$time_format = get_option( 'time_format' );
1226 1226
 		}
1227 1227
 
1228 1228
 		$trimmed_format = trim( $time_format );
@@ -1268,10 +1268,10 @@  discard block
 block discarded – undo
1268 1268
 		$time_strings = self::get_time_strings();
1269 1269
 
1270 1270
 		foreach ( $time_strings as $k => $v ) {
1271
-			if ( $diff[ $k ] ) {
1272
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1271
+			if ( $diff[$k] ) {
1272
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1273 1273
 			} else {
1274
-				unset( $time_strings[ $k ] );
1274
+				unset( $time_strings[$k] );
1275 1275
 			}
1276 1276
 		}
1277 1277
 
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
      */
1310 1310
 	public static function esc_like( $term ) {
1311 1311
         global $wpdb;
1312
-        if ( method_exists($wpdb, 'esc_like') ) {
1312
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1313 1313
 			// WP 4.0
1314 1314
             $term = $wpdb->esc_like( $term );
1315 1315
         } else {
@@ -1323,17 +1323,17 @@  discard block
 block discarded – undo
1323 1323
      * @param string $order_query
1324 1324
      */
1325 1325
 	public static function esc_order( $order_query ) {
1326
-        if ( empty($order_query) ) {
1326
+        if ( empty( $order_query ) ) {
1327 1327
             return '';
1328 1328
         }
1329 1329
 
1330 1330
         // remove ORDER BY before santizing
1331
-        $order_query = strtolower($order_query);
1332
-        if ( strpos($order_query, 'order by') !== false ) {
1333
-            $order_query = str_replace('order by', '', $order_query);
1331
+        $order_query = strtolower( $order_query );
1332
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1333
+            $order_query = str_replace( 'order by', '', $order_query );
1334 1334
         }
1335 1335
 
1336
-        $order_query = explode(' ', trim($order_query));
1336
+        $order_query = explode( ' ', trim( $order_query ) );
1337 1337
 
1338 1338
         $order_fields = array(
1339 1339
             'id', 'form_key', 'name', 'description',
@@ -1341,13 +1341,13 @@  discard block
 block discarded – undo
1341 1341
             'default_template', 'status', 'created_at',
1342 1342
         );
1343 1343
 
1344
-        $order = trim(trim(reset($order_query), ','));
1345
-        if ( ! in_array($order, $order_fields) ) {
1344
+        $order = trim( trim( reset( $order_query ), ',' ) );
1345
+        if ( ! in_array( $order, $order_fields ) ) {
1346 1346
             return '';
1347 1347
         }
1348 1348
 
1349 1349
         $order_by = '';
1350
-        if ( count($order_query) > 1 ) {
1350
+        if ( count( $order_query ) > 1 ) {
1351 1351
 			$order_by = end( $order_query );
1352 1352
 			self::esc_order_by( $order_by );
1353 1353
         }
@@ -1369,23 +1369,23 @@  discard block
 block discarded – undo
1369 1369
      * @param string $limit
1370 1370
      */
1371 1371
 	public static function esc_limit( $limit ) {
1372
-        if ( empty($limit) ) {
1372
+        if ( empty( $limit ) ) {
1373 1373
             return '';
1374 1374
         }
1375 1375
 
1376
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1377
-        if ( is_numeric($limit) ) {
1376
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1377
+        if ( is_numeric( $limit ) ) {
1378 1378
 			return ' LIMIT ' . $limit;
1379 1379
         }
1380 1380
 
1381
-        $limit = explode(',', trim($limit));
1381
+        $limit = explode( ',', trim( $limit ) );
1382 1382
         foreach ( $limit as $k => $l ) {
1383 1383
             if ( is_numeric( $l ) ) {
1384
-                $limit[ $k ] = $l;
1384
+                $limit[$k] = $l;
1385 1385
             }
1386 1386
         }
1387 1387
 
1388
-        $limit = implode(',', $limit);
1388
+        $limit = implode( ',', $limit );
1389 1389
 		return ' LIMIT ' . $limit;
1390 1390
     }
1391 1391
 
@@ -1394,12 +1394,12 @@  discard block
 block discarded – undo
1394 1394
      * @since 2.0
1395 1395
      */
1396 1396
     public static function prepare_array_values( $array, $type = '%s' ) {
1397
-        $placeholders = array_fill(0, count($array), $type);
1398
-        return implode(', ', $placeholders);
1397
+        $placeholders = array_fill( 0, count( $array ), $type );
1398
+        return implode( ', ', $placeholders );
1399 1399
     }
1400 1400
 
1401 1401
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1402
-        if ( empty($where) ) {
1402
+        if ( empty( $where ) ) {
1403 1403
             return '';
1404 1404
         }
1405 1405
 
@@ -1440,19 +1440,19 @@  discard block
 block discarded – undo
1440 1440
 	public static function json_to_array( $json_vars ) {
1441 1441
         $vars = array();
1442 1442
         foreach ( $json_vars as $jv ) {
1443
-            $jv_name = explode('[', $jv['name']);
1444
-            $last = count($jv_name) - 1;
1443
+            $jv_name = explode( '[', $jv['name'] );
1444
+            $last = count( $jv_name ) - 1;
1445 1445
             foreach ( $jv_name as $p => $n ) {
1446
-                $name = trim($n, ']');
1447
-                if ( ! isset($l1) ) {
1446
+                $name = trim( $n, ']' );
1447
+                if ( ! isset( $l1 ) ) {
1448 1448
                     $l1 = $name;
1449 1449
                 }
1450 1450
 
1451
-                if ( ! isset($l2) ) {
1451
+                if ( ! isset( $l2 ) ) {
1452 1452
                     $l2 = $name;
1453 1453
                 }
1454 1454
 
1455
-                if ( ! isset($l3) ) {
1455
+                if ( ! isset( $l3 ) ) {
1456 1456
                     $l3 = $name;
1457 1457
                 }
1458 1458
 
@@ -1466,24 +1466,24 @@  discard block
 block discarded – undo
1466 1466
 
1467 1467
                     case 1:
1468 1468
                         $l2 = $name;
1469
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1469
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1470 1470
                     break;
1471 1471
 
1472 1472
                     case 2:
1473 1473
                         $l3 = $name;
1474
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1474
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1475 1475
                     break;
1476 1476
 
1477 1477
                     case 3:
1478 1478
                         $l4 = $name;
1479
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1479
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1480 1480
                     break;
1481 1481
                 }
1482 1482
 
1483
-                unset($this_val, $n);
1483
+                unset( $this_val, $n );
1484 1484
             }
1485 1485
 
1486
-            unset($last, $jv);
1486
+            unset( $last, $jv );
1487 1487
         }
1488 1488
 
1489 1489
         return $vars;
@@ -1496,8 +1496,8 @@  discard block
 block discarded – undo
1496 1496
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1497 1497
         if ( $name == '' ) {
1498 1498
             $vars[] = $val;
1499
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1500
-            $vars[ $l1 ] = $val;
1499
+        } else if ( ! isset( $vars[$l1] ) ) {
1500
+            $vars[$l1] = $val;
1501 1501
         }
1502 1502
     }
1503 1503
 
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
             '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() ) ),
1513 1513
         );
1514 1514
 
1515
-        if ( ! isset( $tooltips[ $name ] ) ) {
1515
+        if ( ! isset( $tooltips[$name] ) ) {
1516 1516
             return;
1517 1517
         }
1518 1518
 
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
             echo ' class="frm_help"';
1523 1523
         }
1524 1524
 
1525
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1525
+		echo ' title="' . esc_attr( $tooltips[$name] );
1526 1526
 
1527 1527
         if ( 'open' != $class ) {
1528 1528
             echo '"';
@@ -1574,13 +1574,13 @@  discard block
 block discarded – undo
1574 1574
     }
1575 1575
 
1576 1576
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1577
-		if ( ! isset( $post_content[ $key ] ) ) {
1577
+		if ( ! isset( $post_content[$key] ) ) {
1578 1578
 			return;
1579 1579
 		}
1580 1580
 
1581 1581
 		if ( is_array( $val ) ) {
1582 1582
 			foreach ( $val as $k1 => $v1 ) {
1583
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1583
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1584 1584
 				unset( $k1, $v1 );
1585 1585
 			}
1586 1586
 		} else {
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 			$val = stripslashes( $val );
1589 1589
 
1590 1590
 			// Add backslashes before double quotes and forward slashes only
1591
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1591
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1592 1592
 		}
1593 1593
 	}
1594 1594
 
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1606 1606
 
1607 1607
 		if ( empty( $settings['ID'] ) ) {
1608
-			unset( $settings['ID']);
1608
+			unset( $settings['ID'] );
1609 1609
 		}
1610 1610
 
1611 1611
 		// delete all caches for this group
@@ -1639,17 +1639,17 @@  discard block
 block discarded – undo
1639 1639
 	}
1640 1640
 
1641 1641
 	public static function maybe_json_decode( $string ) {
1642
-        if ( is_array($string) ) {
1642
+        if ( is_array( $string ) ) {
1643 1643
             return $string;
1644 1644
         }
1645 1645
 
1646
-        $new_string = json_decode($string, true);
1647
-        if ( function_exists('json_last_error') ) {
1646
+        $new_string = json_decode( $string, true );
1647
+        if ( function_exists( 'json_last_error' ) ) {
1648 1648
 			// php 5.3+
1649 1649
             if ( json_last_error() == JSON_ERROR_NONE ) {
1650 1650
                 $string = $new_string;
1651 1651
             }
1652
-        } else if ( isset($new_string) ) {
1652
+        } else if ( isset( $new_string ) ) {
1653 1653
 			// php < 5.3 fallback
1654 1654
             $string = $new_string;
1655 1655
         }
@@ -1665,11 +1665,11 @@  discard block
 block discarded – undo
1665 1665
 	public static function maybe_highlight_menu( $post_type ) {
1666 1666
         global $post;
1667 1667
 
1668
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1668
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1669 1669
             return;
1670 1670
         }
1671 1671
 
1672
-        if ( is_object($post) && $post->post_type != $post_type ) {
1672
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1673 1673
             return;
1674 1674
         }
1675 1675
 
@@ -1768,11 +1768,11 @@  discard block
 block discarded – undo
1768 1768
         $frm_version = self::plugin_version();
1769 1769
 
1770 1770
         // check if Formidable meets minimum requirements
1771
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1771
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1772 1772
             return;
1773 1773
         }
1774 1774
 
1775
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1775
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1776 1776
 		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">' .
1777 1777
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1778 1778
         '</div></td></tr>';
@@ -1780,38 +1780,38 @@  discard block
 block discarded – undo
1780 1780
 
1781 1781
     public static function locales( $type = 'date' ) {
1782 1782
         $locales = array(
1783
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1784
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1785
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1783
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1784
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1785
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1786 1786
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1787
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1788
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1787
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1788
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1789 1789
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1790
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1791
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1790
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1791
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1792 1792
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1793
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1793
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1794 1794
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1795
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1795
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1796 1796
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1797
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1797
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1798 1798
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1799
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1800
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1801
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1802
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1803
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1799
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1800
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1801
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1802
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1803
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1804 1804
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1805
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1805
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1806 1806
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1807 1807
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1808
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1808
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1809 1809
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1810
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1810
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1811 1811
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1812
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1813
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1814
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1812
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1813
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1814
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1815 1815
         );
1816 1816
 
1817 1817
         if ( $type == 'captcha' ) {
@@ -1830,8 +1830,8 @@  discard block
 block discarded – undo
1830 1830
             );
1831 1831
         }
1832 1832
 
1833
-        $locales = array_diff_key($locales, array_flip($unset));
1834
-        $locales = apply_filters('frm_locales', $locales);
1833
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1834
+        $locales = apply_filters( 'frm_locales', $locales );
1835 1835
 
1836 1836
         return $locales;
1837 1837
     }
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -1 removed lines patch added patch discarded remove patch
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 * Sanitize the value, and allow some HTML
363 363
 	 * @since 2.0
364 364
 	 * @param string $value
365
-	 * @param array $allowed
365
+	 * @param string[] $allowed
366 366
 	 * @return string
367 367
 	 */
368 368
 	public static function kses( $value, $allowed = array() ) {
@@ -779,6 +779,9 @@  discard block
 block discarded – undo
779 779
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
780 780
     }
781 781
 
782
+	/**
783
+	 * @param string $function
784
+	 */
782 785
 	public static function recursive_function_map( $value, $function ) {
783 786
 		if ( is_array( $value ) ) {
784 787
 			$original_function = $function;
@@ -1198,6 +1201,9 @@  discard block
 block discarded – undo
1198 1201
         return $sub . (($len < $original_len) ? $continue : '');
1199 1202
     }
1200 1203
 
1204
+	/**
1205
+	 * @param string[] $function_names
1206
+	 */
1201 1207
 	public static function mb_function( $function_names, $args ) {
1202 1208
 		$mb_function_name = $function_names[0];
1203 1209
 		$function_name = $function_names[1];
@@ -1231,6 +1237,9 @@  discard block
 block discarded – undo
1231 1237
         return $formatted;
1232 1238
     }
1233 1239
 
1240
+	/**
1241
+	 * @param string $time_format
1242
+	 */
1234 1243
 	private static function add_time_to_date( $time_format, $date ) {
1235 1244
 		if ( empty( $time_format ) ) {
1236 1245
 			$time_format = get_option('time_format');
Please login to merge, or discard this patch.
Indentation   +1041 added lines, -1041 removed lines patch added patch discarded remove patch
@@ -12,50 +12,50 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.02.06';
14 14
 
15
-    /**
16
-     * @since 1.07.02
17
-     *
18
-     * @param none
19
-     * @return string The version of this plugin
20
-     */
21
-    public static function plugin_version() {
22
-        return self::$plug_version;
23
-    }
24
-
25
-    public static function plugin_folder() {
26
-        return basename(self::plugin_path());
27
-    }
28
-
29
-    public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
31
-    }
32
-
33
-    public static function plugin_url() {
34
-        //prevously FRM_URL constant
15
+	/**
16
+	 * @since 1.07.02
17
+	 *
18
+	 * @param none
19
+	 * @return string The version of this plugin
20
+	 */
21
+	public static function plugin_version() {
22
+		return self::$plug_version;
23
+	}
24
+
25
+	public static function plugin_folder() {
26
+		return basename(self::plugin_path());
27
+	}
28
+
29
+	public static function plugin_path() {
30
+		return dirname(dirname(dirname(__FILE__)));
31
+	}
32
+
33
+	public static function plugin_url() {
34
+		//prevously FRM_URL constant
35 35
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
36
-    }
36
+	}
37 37
 
38 38
 	public static function relative_plugin_url() {
39 39
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
40 40
 	}
41 41
 
42
-    /**
43
-     * @return string Site URL
44
-     */
45
-    public static function site_url() {
46
-        return site_url();
47
-    }
48
-
49
-    /**
50
-     * Get the name of this site
51
-     * Used for [sitename] shortcode
52
-     *
53
-     * @since 2.0
54
-     * @return string
55
-     */
56
-    public static function site_name() {
57
-        return get_option('blogname');
58
-    }
42
+	/**
43
+	 * @return string Site URL
44
+	 */
45
+	public static function site_url() {
46
+		return site_url();
47
+	}
48
+
49
+	/**
50
+	 * Get the name of this site
51
+	 * Used for [sitename] shortcode
52
+	 *
53
+	 * @since 2.0
54
+	 * @return string
55
+	 */
56
+	public static function site_name() {
57
+		return get_option('blogname');
58
+	}
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
61 61
 		$affiliate_id = self::get_affiliate();
@@ -76,83 +76,83 @@  discard block
 block discarded – undo
76 76
 		return $affiliate_id;
77 77
 	}
78 78
 
79
-    /**
80
-     * Get the Formidable settings
81
-     *
82
-     * @since 2.0
83
-     *
84
-     * @param None
85
-     * @return FrmSettings $frm_setings
86
-     */
87
-    public static function get_settings() {
88
-        global $frm_settings;
89
-        if ( empty($frm_settings) ) {
90
-            $frm_settings = new FrmSettings();
91
-        }
92
-        return $frm_settings;
93
-    }
79
+	/**
80
+	 * Get the Formidable settings
81
+	 *
82
+	 * @since 2.0
83
+	 *
84
+	 * @param None
85
+	 * @return FrmSettings $frm_setings
86
+	 */
87
+	public static function get_settings() {
88
+		global $frm_settings;
89
+		if ( empty($frm_settings) ) {
90
+			$frm_settings = new FrmSettings();
91
+		}
92
+		return $frm_settings;
93
+	}
94 94
 
95 95
 	public static function get_menu_name() {
96 96
 		$frm_settings = FrmAppHelper::get_settings();
97 97
 		return $frm_settings->menu;
98 98
 	}
99 99
 
100
-    /**
101
-     * Show a message in place of pro features
102
-     *
103
-     * @since 2.0
104
-     */
100
+	/**
101
+	 * Show a message in place of pro features
102
+	 *
103
+	 * @since 2.0
104
+	 */
105 105
 	public static function update_message() {
106 106
 		_deprecated_function( __FUNCTION__, '2.0.19' );
107
-    }
108
-
109
-    public static function pro_is_installed() {
110
-        return apply_filters('frm_pro_installed', false);
111
-    }
112
-
113
-    /**
114
-     * Check for certain page in Formidable settings
115
-     *
116
-     * @since 2.0
117
-     *
118
-     * @param string $page The name of the page to check
119
-     * @return boolean
120
-     */
107
+	}
108
+
109
+	public static function pro_is_installed() {
110
+		return apply_filters('frm_pro_installed', false);
111
+	}
112
+
113
+	/**
114
+	 * Check for certain page in Formidable settings
115
+	 *
116
+	 * @since 2.0
117
+	 *
118
+	 * @param string $page The name of the page to check
119
+	 * @return boolean
120
+	 */
121 121
 	public static function is_admin_page( $page = 'formidable' ) {
122
-        global $pagenow;
122
+		global $pagenow;
123 123
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
124
-        if ( $pagenow ) {
124
+		if ( $pagenow ) {
125 125
 			return $pagenow == 'admin.php' && $get_page == $page;
126
-        }
126
+		}
127 127
 
128 128
 		return is_admin() && $get_page == $page;
129
-    }
130
-
131
-    /**
132
-     * Check for the form preview page
133
-     *
134
-     * @since 2.0
135
-     *
136
-     * @param None
137
-     * @return boolean
138
-     */
139
-    public static function is_preview_page() {
140
-        global $pagenow;
129
+	}
130
+
131
+	/**
132
+	 * Check for the form preview page
133
+	 *
134
+	 * @since 2.0
135
+	 *
136
+	 * @param None
137
+	 * @return boolean
138
+	 */
139
+	public static function is_preview_page() {
140
+		global $pagenow;
141 141
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
142 142
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
143
-    }
144
-
145
-    /**
146
-     * Check for ajax except the form preview page
147
-     *
148
-     * @since 2.0
149
-     *
150
-     * @param None
151
-     * @return boolean
152
-     */
153
-    public static function doing_ajax() {
154
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
155
-    }
143
+	}
144
+
145
+	/**
146
+	 * Check for ajax except the form preview page
147
+	 *
148
+	 * @since 2.0
149
+	 *
150
+	 * @param None
151
+	 * @return boolean
152
+	 */
153
+	public static function doing_ajax() {
154
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
155
+	}
156 156
 
157 157
 	/**
158 158
 	 * @since 2.0.8
@@ -162,102 +162,102 @@  discard block
 block discarded – undo
162 162
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
163 163
 	}
164 164
 
165
-    /**
166
-     * Check if on an admin page
167
-     *
168
-     * @since 2.0
169
-     *
170
-     * @param None
171
-     * @return boolean
172
-     */
173
-    public static function is_admin() {
174
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
175
-    }
176
-
177
-    /**
178
-     * Check if value contains blank value or empty array
179
-     *
180
-     * @since 2.0
181
-     * @param mixed $value - value to check
165
+	/**
166
+	 * Check if on an admin page
167
+	 *
168
+	 * @since 2.0
169
+	 *
170
+	 * @param None
171
+	 * @return boolean
172
+	 */
173
+	public static function is_admin() {
174
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
175
+	}
176
+
177
+	/**
178
+	 * Check if value contains blank value or empty array
179
+	 *
180
+	 * @since 2.0
181
+	 * @param mixed $value - value to check
182 182
 	 * @param string
183
-     * @return boolean
184
-     */
185
-    public static function is_empty_value( $value, $empty = '' ) {
186
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
187
-    }
188
-
189
-    public static function is_not_empty_value( $value, $empty = '' ) {
190
-        return ! self::is_empty_value( $value, $empty );
191
-    }
192
-
193
-    /**
194
-     * Get any value from the $_SERVER
195
-     *
196
-     * @since 2.0
197
-     * @param string $value
198
-     * @return string
199
-     */
183
+	 * @return boolean
184
+	 */
185
+	public static function is_empty_value( $value, $empty = '' ) {
186
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
187
+	}
188
+
189
+	public static function is_not_empty_value( $value, $empty = '' ) {
190
+		return ! self::is_empty_value( $value, $empty );
191
+	}
192
+
193
+	/**
194
+	 * Get any value from the $_SERVER
195
+	 *
196
+	 * @since 2.0
197
+	 * @param string $value
198
+	 * @return string
199
+	 */
200 200
 	public static function get_server_value( $value ) {
201
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
202
-    }
203
-
204
-    /**
205
-     * Check for the IP address in several places
206
-     * Used by [ip] shortcode
207
-     *
208
-     * @return string The IP address of the current user
209
-     */
210
-    public static function get_ip_address() {
201
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
202
+	}
203
+
204
+	/**
205
+	 * Check for the IP address in several places
206
+	 * Used by [ip] shortcode
207
+	 *
208
+	 * @return string The IP address of the current user
209
+	 */
210
+	public static function get_ip_address() {
211 211
 		$ip = '';
212
-        foreach ( array(
213
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215
-        ) as $key ) {
216
-            if ( ! isset( $_SERVER[ $key ] ) ) {
217
-                continue;
218
-            }
219
-
220
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
-                $ip = trim($ip); // just to be safe
222
-
223
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
224
-                    return $ip;
225
-                }
226
-            }
227
-        }
212
+		foreach ( array(
213
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215
+		) as $key ) {
216
+			if ( ! isset( $_SERVER[ $key ] ) ) {
217
+				continue;
218
+			}
219
+
220
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
+				$ip = trim($ip); // just to be safe
222
+
223
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
224
+					return $ip;
225
+				}
226
+			}
227
+		}
228 228
 
229 229
 		return sanitize_text_field( $ip );
230
-    }
230
+	}
231 231
 
232
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
-        if ( strpos($param, '[') ) {
234
-            $params = explode('[', $param);
235
-            $param = $params[0];
236
-        }
232
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
+		if ( strpos($param, '[') ) {
234
+			$params = explode('[', $param);
235
+			$param = $params[0];
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( urldecode( $_GET[ $param ] ) ) );
242
-            }
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( urldecode( $_GET[ $param ] ) ) );
242
+			}
243 243
 			self::sanitize_value( $sanitize, $value );
244 244
 		} else {
245
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
246
-        }
245
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
246
+		}
247 247
 
248 248
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
249
-            foreach ( $params as $k => $p ) {
250
-                if ( ! $k || ! is_array($value) ) {
251
-                    continue;
252
-                }
249
+			foreach ( $params as $k => $p ) {
250
+				if ( ! $k || ! is_array($value) ) {
251
+					continue;
252
+				}
253 253
 
254
-                $p = trim($p, ']');
255
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
256
-            }
257
-        }
254
+				$p = trim($p, ']');
255
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
256
+			}
257
+		}
258 258
 
259
-        return $value;
260
-    }
259
+		return $value;
260
+	}
261 261
 
262 262
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
263 263
 		return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
275 275
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
276
-    }
276
+	}
277 277
 
278 278
 	/**
279 279
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
 	}
310 310
 
311 311
 	/**
312
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
313
-	*
314
-	* @since 2.0.8
315
-	* @param string $value
316
-	* @return string $value
317
-	*/
312
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
313
+	 *
314
+	 * @since 2.0.8
315
+	 * @param string $value
316
+	 * @return string $value
317
+	 */
318 318
 	public static function preserve_backslashes( $value ) {
319 319
 		// If backslashes have already been added, don't add them again
320 320
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
 		}
337 337
 	}
338 338
 
339
-    public static function sanitize_request( $sanitize_method, &$values ) {
340
-        $temp_values = $values;
341
-        foreach ( $temp_values as $k => $val ) {
342
-            if ( isset( $sanitize_method[ $k ] ) ) {
339
+	public static function sanitize_request( $sanitize_method, &$values ) {
340
+		$temp_values = $values;
341
+		foreach ( $temp_values as $k => $val ) {
342
+			if ( isset( $sanitize_method[ $k ] ) ) {
343 343
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
344
-            }
345
-        }
346
-    }
344
+			}
345
+		}
346
+	}
347 347
 
348 348
 	public static function sanitize_array( &$values ) {
349 349
 		$temp_values = $values;
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	public static function kses( $value, $allowed = array() ) {
363 363
 		$html = array(
364
-		    'a' => array(
364
+			'a' => array(
365 365
 				'href'  => array(),
366 366
 				'title' => array(),
367 367
 				'id'    => array(),
368 368
 				'class' => array(),
369
-		    ),
369
+			),
370 370
 		);
371 371
 
372 372
 		$allowed_html = array();
@@ -377,126 +377,126 @@  discard block
 block discarded – undo
377 377
 		return wp_kses( $value, $allowed_html );
378 378
 	}
379 379
 
380
-    /**
381
-     * Used when switching the action for a bulk action
382
-     * @since 2.0
383
-     */
384
-    public static function remove_get_action() {
385
-        if ( ! isset($_GET) ) {
386
-            return;
387
-        }
380
+	/**
381
+	 * Used when switching the action for a bulk action
382
+	 * @since 2.0
383
+	 */
384
+	public static function remove_get_action() {
385
+		if ( ! isset($_GET) ) {
386
+			return;
387
+		}
388 388
 
389
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
390
-        if ( ! empty( $new_action ) ) {
389
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
390
+		if ( ! empty( $new_action ) ) {
391 391
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
392
-        }
393
-    }
394
-
395
-    /**
396
-     * Check the WP query for a parameter
397
-     *
398
-     * @since 2.0
399
-     * @return string|array
400
-     */
401
-    public static function get_query_var( $value, $param ) {
402
-        if ( $value != '' ) {
403
-            return $value;
404
-        }
405
-
406
-        global $wp_query;
407
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
-            $value = $wp_query->query_vars[ $param ];
409
-        }
410
-
411
-        return $value;
412
-    }
413
-
414
-    /**
415
-     * @param string $type
416
-     */
417
-    public static function trigger_hook_load( $type, $object = null ) {
418
-        // only load the form hooks once
392
+		}
393
+	}
394
+
395
+	/**
396
+	 * Check the WP query for a parameter
397
+	 *
398
+	 * @since 2.0
399
+	 * @return string|array
400
+	 */
401
+	public static function get_query_var( $value, $param ) {
402
+		if ( $value != '' ) {
403
+			return $value;
404
+		}
405
+
406
+		global $wp_query;
407
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
+			$value = $wp_query->query_vars[ $param ];
409
+		}
410
+
411
+		return $value;
412
+	}
413
+
414
+	/**
415
+	 * @param string $type
416
+	 */
417
+	public static function trigger_hook_load( $type, $object = null ) {
418
+		// only load the form hooks once
419 419
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
420
-        if ( ! $hooks_loaded ) {
420
+		if ( ! $hooks_loaded ) {
421 421
 			do_action( 'frm_load_' . $type . '_hooks' );
422
-        }
423
-    }
424
-
425
-    /**
426
-     * Check cache before fetching values and saving to cache
427
-     *
428
-     * @since 2.0
429
-     *
430
-     * @param string $cache_key The unique name for this cache
431
-     * @param string $group The name of the cache group
432
-     * @param string $query If blank, don't run a db call
433
-     * @param string $type The wpdb function to use with this query
434
-     * @return mixed $results The cache or query results
435
-     */
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) ) {
439
-            return $results;
440
-        }
441
-
442
-        if ( 'get_posts' == $type ) {
443
-            $results = get_posts($query);
422
+		}
423
+	}
424
+
425
+	/**
426
+	 * Check cache before fetching values and saving to cache
427
+	 *
428
+	 * @since 2.0
429
+	 *
430
+	 * @param string $cache_key The unique name for this cache
431
+	 * @param string $group The name of the cache group
432
+	 * @param string $query If blank, don't run a db call
433
+	 * @param string $type The wpdb function to use with this query
434
+	 * @return mixed $results The cache or query results
435
+	 */
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) ) {
439
+			return $results;
440
+		}
441
+
442
+		if ( 'get_posts' == $type ) {
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
-        } else {
448
-            global $wpdb;
449
-            $results = $wpdb->{$type}($query);
450
-        }
447
+		} else {
448
+			global $wpdb;
449
+			$results = $wpdb->{$type}($query);
450
+		}
451 451
 
452 452
 		if ( ! self::prevent_caching() ) {
453 453
 			wp_cache_set( $cache_key, $results, $group, $time );
454 454
 		}
455 455
 
456
-        return $results;
457
-    }
456
+		return $results;
457
+	}
458 458
 
459
-    /**
460
-     * Data that should be stored for a long time can be stored in a transient.
461
-     * First check the cache, then check the transient
462
-     * @since 2.0
463
-     * @return mixed The cached value or false
464
-     */
459
+	/**
460
+	 * Data that should be stored for a long time can be stored in a transient.
461
+	 * First check the cache, then check the transient
462
+	 * @since 2.0
463
+	 * @return mixed The cached value or false
464
+	 */
465 465
 	public static function check_cache_and_transient( $cache_key ) {
466
-        // check caching layer first
467
-        $results = self::check_cache( $cache_key );
468
-        if ( $results ) {
469
-            return $results;
470
-        }
471
-
472
-        // then check the transient
473
-        $results = get_transient($cache_key);
474
-        if ( $results ) {
475
-            wp_cache_set($cache_key, $results);
476
-        }
477
-
478
-        return $results;
479
-    }
480
-
481
-    /**
482
-     * @since 2.0
483
-     * @param string $cache_key
484
-     */
466
+		// check caching layer first
467
+		$results = self::check_cache( $cache_key );
468
+		if ( $results ) {
469
+			return $results;
470
+		}
471
+
472
+		// then check the transient
473
+		$results = get_transient($cache_key);
474
+		if ( $results ) {
475
+			wp_cache_set($cache_key, $results);
476
+		}
477
+
478
+		return $results;
479
+	}
480
+
481
+	/**
482
+	 * @since 2.0
483
+	 * @param string $cache_key
484
+	 */
485 485
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
486 486
 		delete_transient($cache_key);
487 487
 		wp_cache_delete( $cache_key, $group );
488 488
 	}
489 489
 
490
-    /**
491
-     * Delete all caching in a single group
492
-     *
493
-     * @since 2.0
494
-     *
495
-     * @param string $group The name of the cache group
496
-     * @return boolean True or False
497
-     */
490
+	/**
491
+	 * Delete all caching in a single group
492
+	 *
493
+	 * @since 2.0
494
+	 *
495
+	 * @param string $group The name of the cache group
496
+	 * @return boolean True or False
497
+	 */
498 498
 	public static function cache_delete_group( $group ) {
499
-    	global $wp_object_cache;
499
+		global $wp_object_cache;
500 500
 
501 501
 		if ( is_callable( array( $wp_object_cache, '__get' ) ) ) {
502 502
 			$group_cache = $wp_object_cache->__get('cache');
@@ -514,37 +514,37 @@  discard block
 block discarded – undo
514 514
 			// When using redis: if ( is_callable( array( $wp_object_cache, 'redis_status' ) ) && $wp_object_cache->redis_status() )
515 515
 		}
516 516
 
517
-    	return false;
518
-    }
517
+		return false;
518
+	}
519 519
 
520
-    /**
521
-     * Check a value from a shortcode to see if true or false.
522
-     * True when value is 1, true, 'true', 'yes'
523
-     *
524
-     * @since 1.07.10
525
-     *
526
-     * @param string $value The value to compare
527
-     * @return boolean True or False
528
-     */
520
+	/**
521
+	 * Check a value from a shortcode to see if true or false.
522
+	 * True when value is 1, true, 'true', 'yes'
523
+	 *
524
+	 * @since 1.07.10
525
+	 *
526
+	 * @param string $value The value to compare
527
+	 * @return boolean True or False
528
+	 */
529 529
 	public static function is_true( $value ) {
530
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
531
-    }
530
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
531
+	}
532 532
 
533
-    /**
534
-     * Used to filter shortcode in text widgets
535
-     */
536
-    public static function widget_text_filter_callback( $matches ) {
537
-        return do_shortcode( $matches[0] );
538
-    }
533
+	/**
534
+	 * Used to filter shortcode in text widgets
535
+	 */
536
+	public static function widget_text_filter_callback( $matches ) {
537
+		return do_shortcode( $matches[0] );
538
+	}
539 539
 
540
-    public static function get_pages() {
540
+	public static function get_pages() {
541 541
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
542
-    }
542
+	}
543 543
 
544
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
545
-        $pages = self::get_pages();
544
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
545
+		$pages = self::get_pages();
546 546
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
547
-    ?>
547
+	?>
548 548
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
549 549
             <option value=""> </option>
550 550
             <?php foreach ( $pages as $page ) { ?>
@@ -554,108 +554,108 @@  discard block
 block discarded – undo
554 554
             <?php } ?>
555 555
         </select>
556 556
     <?php
557
-    }
557
+	}
558 558
 
559 559
 	public static function post_edit_link( $post_id ) {
560
-        $post = get_post($post_id);
561
-        if ( $post ) {
560
+		$post = get_post($post_id);
561
+		if ( $post ) {
562 562
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
563 563
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
564
-        }
565
-        return '';
566
-    }
564
+		}
565
+		return '';
566
+	}
567 567
 
568 568
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
569
-    ?>
569
+	?>
570 570
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
571
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
572
-            ?> class="frm_multiselect">
571
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
572
+			?> class="frm_multiselect">
573 573
             <?php self::roles_options($capability); ?>
574 574
         </select>
575 575
     <?php
576
-    }
576
+	}
577 577
 
578 578
 	public static function roles_options( $capability ) {
579
-        global $frm_vars;
580
-        if ( isset($frm_vars['editable_roles']) ) {
581
-            $editable_roles = $frm_vars['editable_roles'];
582
-        } else {
583
-            $editable_roles = get_editable_roles();
584
-            $frm_vars['editable_roles'] = $editable_roles;
585
-        }
586
-
587
-        foreach ( $editable_roles as $role => $details ) {
588
-            $name = translate_user_role($details['name'] ); ?>
579
+		global $frm_vars;
580
+		if ( isset($frm_vars['editable_roles']) ) {
581
+			$editable_roles = $frm_vars['editable_roles'];
582
+		} else {
583
+			$editable_roles = get_editable_roles();
584
+			$frm_vars['editable_roles'] = $editable_roles;
585
+		}
586
+
587
+		foreach ( $editable_roles as $role => $details ) {
588
+			$name = translate_user_role($details['name'] ); ?>
589 589
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
590 590
 <?php
591
-            unset($role, $details);
592
-        }
593
-    }
591
+			unset($role, $details);
592
+		}
593
+	}
594 594
 
595 595
 	public static function frm_capabilities( $type = 'auto' ) {
596
-        $cap = array(
597
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
598
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
599
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
600
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
601
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
602
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
603
-        );
596
+		$cap = array(
597
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
598
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
599
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
600
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
601
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
602
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
603
+		);
604 604
 
605 605
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
606
-            return $cap;
607
-        }
606
+			return $cap;
607
+		}
608 608
 
609
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
610
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
611
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
612
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
609
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
610
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
611
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
612
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
613 613
 
614
-        return $cap;
615
-    }
614
+		return $cap;
615
+	}
616 616
 
617 617
 	public static function user_has_permission( $needed_role ) {
618
-        if ( $needed_role == '-1' ) {
619
-            return false;
618
+		if ( $needed_role == '-1' ) {
619
+			return false;
620 620
 		}
621 621
 
622
-        // $needed_role will be equal to blank if "Logged-in users" is selected
623
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
624
-            return true;
625
-        }
622
+		// $needed_role will be equal to blank if "Logged-in users" is selected
623
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
624
+			return true;
625
+		}
626 626
 
627
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
628
-        foreach ( $roles as $role ) {
627
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
628
+		foreach ( $roles as $role ) {
629 629
 			if ( current_user_can( $role ) ) {
630
-        		return true;
630
+				return true;
631 631
 			}
632
-        	if ( $role == $needed_role ) {
633
-        		break;
632
+			if ( $role == $needed_role ) {
633
+				break;
634 634
 			}
635
-        }
636
-        return false;
637
-    }
638
-
639
-    /**
640
-     * Make sure administrators can see Formidable menu
641
-     *
642
-     * @since 2.0
643
-     */
644
-    public static function maybe_add_permissions() {
635
+		}
636
+		return false;
637
+	}
638
+
639
+	/**
640
+	 * Make sure administrators can see Formidable menu
641
+	 *
642
+	 * @since 2.0
643
+	 */
644
+	public static function maybe_add_permissions() {
645 645
 		self::force_capability( 'frm_view_entries' );
646 646
 
647
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
648
-            return;
649
-        }
647
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
648
+			return;
649
+		}
650 650
 
651 651
 		$user_id = get_current_user_id();
652 652
 		$user = new WP_User( $user_id );
653
-        $frm_roles = self::frm_capabilities();
654
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
653
+		$frm_roles = self::frm_capabilities();
654
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
655 655
 			$user->add_cap( $frm_role );
656
-            unset($frm_role, $frm_role_description);
657
-        }
658
-    }
656
+			unset($frm_role, $frm_role_description);
657
+		}
658
+	}
659 659
 
660 660
 	/**
661 661
 	 * Make sure admins have permission to see the menu items
@@ -671,28 +671,28 @@  discard block
 block discarded – undo
671 671
 		}
672 672
 	}
673 673
 
674
-    /**
675
-     * Check if the user has permision for action.
676
-     * Return permission message and stop the action if no permission
677
-     * @since 2.0
678
-     * @param string $permission
679
-     */
674
+	/**
675
+	 * Check if the user has permision for action.
676
+	 * Return permission message and stop the action if no permission
677
+	 * @since 2.0
678
+	 * @param string $permission
679
+	 */
680 680
 	public static function permission_check( $permission, $show_message = 'show' ) {
681
-        $permission_error = self::permission_nonce_error($permission);
682
-        if ( $permission_error !== false ) {
683
-            if ( 'hide' == $show_message ) {
684
-                $permission_error = '';
685
-            }
686
-            wp_die($permission_error);
687
-        }
688
-    }
689
-
690
-    /**
691
-     * Check user permission and nonce
692
-     * @since 2.0
693
-     * @param string $permission
694
-     * @return false|string The permission message or false if allowed
695
-     */
681
+		$permission_error = self::permission_nonce_error($permission);
682
+		if ( $permission_error !== false ) {
683
+			if ( 'hide' == $show_message ) {
684
+				$permission_error = '';
685
+			}
686
+			wp_die($permission_error);
687
+		}
688
+	}
689
+
690
+	/**
691
+	 * Check user permission and nonce
692
+	 * @since 2.0
693
+	 * @param string $permission
694
+	 * @return false|string The permission message or false if allowed
695
+	 */
696 696
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
697 697
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
698 698
 			$frm_settings = self::get_settings();
@@ -700,23 +700,23 @@  discard block
 block discarded – undo
700 700
 		}
701 701
 
702 702
 		$error = false;
703
-        if ( empty($nonce_name) ) {
704
-            return $error;
705
-        }
703
+		if ( empty($nonce_name) ) {
704
+			return $error;
705
+		}
706 706
 
707
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
708
-            $frm_settings = self::get_settings();
709
-            $error = $frm_settings->admin_permission;
710
-        }
707
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
708
+			$frm_settings = self::get_settings();
709
+			$error = $frm_settings->admin_permission;
710
+		}
711 711
 
712
-        return $error;
713
-    }
712
+		return $error;
713
+	}
714 714
 
715
-    public static function checked( $values, $current ) {
715
+	public static function checked( $values, $current ) {
716 716
 		if ( self::check_selected( $values, $current ) ) {
717
-            echo ' checked="checked"';
717
+			echo ' checked="checked"';
718 718
 		}
719
-    }
719
+	}
720 720
 
721 721
 	public static function check_selected( $values, $current ) {
722 722
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -726,50 +726,50 @@  discard block
 block discarded – undo
726 726
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
727 727
 	}
728 728
 
729
-    /**
730
-    * Check if current field option is an "other" option
731
-    *
732
-    * @since 2.0
733
-    *
734
-    * @param string $opt_key
735
-    * @return boolean Returns true if current field option is an "Other" option
736
-    */
737
-    public static function is_other_opt( $opt_key ) {
738
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
739
-        return FrmFieldsHelper::is_other_opt( $opt_key );
740
-    }
741
-
742
-    /**
743
-    * Get value that belongs in "Other" text box
744
-    *
745
-    * @since 2.0
746
-    *
747
-    * @param string $opt_key
748
-    * @param array $field
749
-    * @return string $other_val
750
-    */
751
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
729
+	/**
730
+	 * Check if current field option is an "other" option
731
+	 *
732
+	 * @since 2.0
733
+	 *
734
+	 * @param string $opt_key
735
+	 * @return boolean Returns true if current field option is an "Other" option
736
+	 */
737
+	public static function is_other_opt( $opt_key ) {
738
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
739
+		return FrmFieldsHelper::is_other_opt( $opt_key );
740
+	}
741
+
742
+	/**
743
+	 * Get value that belongs in "Other" text box
744
+	 *
745
+	 * @since 2.0
746
+	 *
747
+	 * @param string $opt_key
748
+	 * @param array $field
749
+	 * @return string $other_val
750
+	 */
751
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
752 752
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
753 753
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
754
-    }
755
-
756
-    /**
757
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
758
-    * Intended for front-end use
759
-    *
760
-    * @since 2.0
761
-    *
762
-    * @param array $field
763
-    * @param boolean $other_opt
764
-    * @param string $checked
765
-    * @param array $args should include opt_key and field name
766
-    * @return string $other_val
767
-    */
768
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
754
+	}
755
+
756
+	/**
757
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
758
+	 * Intended for front-end use
759
+	 *
760
+	 * @since 2.0
761
+	 *
762
+	 * @param array $field
763
+	 * @param boolean $other_opt
764
+	 * @param string $checked
765
+	 * @param array $args should include opt_key and field name
766
+	 * @return string $other_val
767
+	 */
768
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
769 769
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
770 770
 		$args['field'] = $field;
771 771
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
772
-    }
772
+	}
773 773
 
774 774
 	public static function recursive_function_map( $value, $function ) {
775 775
 		if ( is_array( $value ) ) {
@@ -799,24 +799,24 @@  discard block
 block discarded – undo
799 799
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
800 800
 	}
801 801
 
802
-    /**
803
-     * Flatten a multi-dimensional array
804
-     */
802
+	/**
803
+	 * Flatten a multi-dimensional array
804
+	 */
805 805
 	public static function array_flatten( $array, $keys = 'keep' ) {
806
-        $return = array();
807
-        foreach ( $array as $key => $value ) {
808
-            if ( is_array($value) ) {
806
+		$return = array();
807
+		foreach ( $array as $key => $value ) {
808
+			if ( is_array($value) ) {
809 809
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
810
-            } else {
810
+			} else {
811 811
 				if ( $keys == 'keep' ) {
812 812
 					$return[ $key ] = $value;
813 813
 				} else {
814 814
 					$return[] = $value;
815 815
 				}
816
-            }
817
-        }
818
-        return $return;
819
-    }
816
+			}
817
+		}
818
+		return $return;
819
+	}
820 820
 
821 821
 	public static function esc_textarea( $text, $is_rich_text = false ) {
822 822
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -827,308 +827,308 @@  discard block
 block discarded – undo
827 827
 		return apply_filters( 'esc_textarea', $safe_text, $text );
828 828
 	}
829 829
 
830
-    /**
831
-     * Add auto paragraphs to text areas
832
-     * @since 2.0
833
-     */
830
+	/**
831
+	 * Add auto paragraphs to text areas
832
+	 * @since 2.0
833
+	 */
834 834
 	public static function use_wpautop( $content ) {
835
-        if ( apply_filters('frm_use_wpautop', true) ) {
836
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
837
-        }
838
-        return $content;
839
-    }
835
+		if ( apply_filters('frm_use_wpautop', true) ) {
836
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
837
+		}
838
+		return $content;
839
+	}
840 840
 
841 841
 	public static function replace_quotes( $val ) {
842
-        //Replace double quotes
842
+		//Replace double quotes
843 843
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
844
-        //Replace single quotes
845
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
846
-        return $val;
847
-    }
848
-
849
-    /**
850
-     * @since 2.0
851
-     * @return string The base Google APIS url for the current version of jQuery UI
852
-     */
853
-    public static function jquery_ui_base_url() {
844
+		//Replace single quotes
845
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
846
+		return $val;
847
+	}
848
+
849
+	/**
850
+	 * @since 2.0
851
+	 * @return string The base Google APIS url for the current version of jQuery UI
852
+	 */
853
+	public static function jquery_ui_base_url() {
854 854
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
855
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
856
-        return $url;
857
-    }
855
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
856
+		return $url;
857
+	}
858 858
 
859
-    /**
860
-     * @param string $handle
861
-     */
859
+	/**
860
+	 * @param string $handle
861
+	 */
862 862
 	public static function script_version( $handle ) {
863
-        global $wp_scripts;
864
-    	if ( ! $wp_scripts ) {
865
-    	    return false;
866
-    	}
863
+		global $wp_scripts;
864
+		if ( ! $wp_scripts ) {
865
+			return false;
866
+		}
867 867
 
868
-        $ver = 0;
868
+		$ver = 0;
869 869
 
870
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
871
-            return $ver;
872
-        }
870
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
871
+			return $ver;
872
+		}
873 873
 
874
-        $query = $wp_scripts->registered[ $handle ];
875
-    	if ( is_object( $query ) ) {
876
-    	    $ver = $query->ver;
877
-    	}
874
+		$query = $wp_scripts->registered[ $handle ];
875
+		if ( is_object( $query ) ) {
876
+			$ver = $query->ver;
877
+		}
878 878
 
879
-    	return $ver;
880
-    }
879
+		return $ver;
880
+	}
881 881
 
882 882
 	public static function js_redirect( $url ) {
883 883
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
884
-    }
884
+	}
885 885
 
886 886
 	public static function get_user_id_param( $user_id ) {
887
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
888
-            return $user_id;
889
-        }
887
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
888
+			return $user_id;
889
+		}
890 890
 
891 891
 		if ( $user_id == 'current' ) {
892 892
 			$user_id = get_current_user_id();
893 893
 		} else {
894
-            if ( is_email($user_id) ) {
895
-                $user = get_user_by('email', $user_id);
896
-            } else {
897
-                $user = get_user_by('login', $user_id);
898
-            }
894
+			if ( is_email($user_id) ) {
895
+				$user = get_user_by('email', $user_id);
896
+			} else {
897
+				$user = get_user_by('login', $user_id);
898
+			}
899 899
 
900
-            if ( $user ) {
901
-                $user_id = $user->ID;
902
-            }
903
-            unset($user);
904
-        }
900
+			if ( $user ) {
901
+				$user_id = $user->ID;
902
+			}
903
+			unset($user);
904
+		}
905 905
 
906
-        return $user_id;
907
-    }
906
+		return $user_id;
907
+	}
908 908
 
909 909
 	public static function get_file_contents( $filename, $atts = array() ) {
910
-        if ( ! is_file($filename) ) {
911
-            return false;
912
-        }
913
-
914
-        extract($atts);
915
-        ob_start();
916
-        include($filename);
917
-        $contents = ob_get_contents();
918
-        ob_end_clean();
919
-        return $contents;
920
-    }
921
-
922
-    /**
923
-     * @param string $table_name
924
-     * @param string $column
910
+		if ( ! is_file($filename) ) {
911
+			return false;
912
+		}
913
+
914
+		extract($atts);
915
+		ob_start();
916
+		include($filename);
917
+		$contents = ob_get_contents();
918
+		ob_end_clean();
919
+		return $contents;
920
+	}
921
+
922
+	/**
923
+	 * @param string $table_name
924
+	 * @param string $column
925 925
 	 * @param int $id
926 926
 	 * @param int $num_chars
927
-     */
928
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
929
-        $key = '';
927
+	 */
928
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
929
+		$key = '';
930 930
 
931
-        if ( ! empty( $name ) ) {
932
-            $key = sanitize_key($name);
933
-        }
931
+		if ( ! empty( $name ) ) {
932
+			$key = sanitize_key($name);
933
+		}
934 934
 
935 935
 		if ( empty( $key ) ) {
936
-            $max_slug_value = pow(36, $num_chars);
937
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
938
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
939
-        }
936
+			$max_slug_value = pow(36, $num_chars);
937
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
938
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
939
+		}
940 940
 
941 941
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
942 942
 			$key = $key . 'a';
943
-        }
943
+		}
944 944
 
945 945
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
946 946
 
947
-        if ( $key_check || is_numeric($key_check) ) {
948
-            $suffix = 2;
947
+		if ( $key_check || is_numeric($key_check) ) {
948
+			$suffix = 2;
949 949
 			do {
950 950
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
951 951
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
952 952
 				$suffix++;
953 953
 			} while ($key_check || is_numeric($key_check));
954 954
 			$key = $alt_post_name;
955
-        }
956
-        return $key;
957
-    }
958
-
959
-    /**
960
-     * Editing a Form or Entry
961
-     * @param string $table
962
-     * @return bool|array
963
-     */
964
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
965
-        if ( ! $record ) {
966
-            return false;
967
-        }
968
-
969
-        if ( empty($post_values) ) {
970
-            $post_values = stripslashes_deep($_POST);
971
-        }
955
+		}
956
+		return $key;
957
+	}
958
+
959
+	/**
960
+	 * Editing a Form or Entry
961
+	 * @param string $table
962
+	 * @return bool|array
963
+	 */
964
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
965
+		if ( ! $record ) {
966
+			return false;
967
+		}
968
+
969
+		if ( empty($post_values) ) {
970
+			$post_values = stripslashes_deep($_POST);
971
+		}
972 972
 
973 973
 		$values = array( 'id' => $record->id, 'fields' => array() );
974 974
 
975 975
 		foreach ( array( 'name', 'description' ) as $var ) {
976
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
976
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
977 977
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
978
-            unset($var, $default_val);
979
-        }
980
-
981
-        $values['description'] = self::use_wpautop($values['description']);
982
-        $frm_settings = self::get_settings();
983
-        $is_form_builder = self::is_admin_page('formidable' );
984
-
985
-        foreach ( (array) $fields as $field ) {
986
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
987
-            if ( ! $is_form_builder ) {
988
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
989
-            }
978
+			unset($var, $default_val);
979
+		}
980
+
981
+		$values['description'] = self::use_wpautop($values['description']);
982
+		$frm_settings = self::get_settings();
983
+		$is_form_builder = self::is_admin_page('formidable' );
984
+
985
+		foreach ( (array) $fields as $field ) {
986
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
987
+			if ( ! $is_form_builder ) {
988
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
989
+			}
990 990
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
991 991
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
992
-        }
992
+		}
993 993
 
994
-        self::fill_form_opts($record, $table, $post_values, $values);
994
+		self::fill_form_opts($record, $table, $post_values, $values);
995 995
 
996
-        if ( $table == 'entries' ) {
997
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
998
-        } else if ( $table == 'forms' ) {
999
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1000
-        }
996
+		if ( $table == 'entries' ) {
997
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
998
+		} else if ( $table == 'forms' ) {
999
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1000
+		}
1001 1001
 
1002
-        return $values;
1003
-    }
1002
+		return $values;
1003
+	}
1004 1004
 
1005 1005
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1006
-        $post_values = $args['post_values'];
1007
-
1008
-        if ( $args['default'] ) {
1009
-            $meta_value = $field->default_value;
1010
-        } else {
1011
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1012
-                if ( ! isset($field->field_options['custom_field']) ) {
1013
-                    $field->field_options['custom_field'] = '';
1014
-                }
1006
+		$post_values = $args['post_values'];
1007
+
1008
+		if ( $args['default'] ) {
1009
+			$meta_value = $field->default_value;
1010
+		} else {
1011
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1012
+				if ( ! isset($field->field_options['custom_field']) ) {
1013
+					$field->field_options['custom_field'] = '';
1014
+				}
1015 1015
 				$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 ) );
1016
-            } else {
1016
+			} else {
1017 1017
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1018
-            }
1019
-        }
1018
+			}
1019
+		}
1020 1020
 
1021 1021
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1022
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1023
-
1024
-        $field_array = array(
1025
-            'id'            => $field->id,
1026
-            'value'         => $new_value,
1027
-            'default_value' => $field->default_value,
1028
-            'name'          => $field->name,
1029
-            'description'   => $field->description,
1030
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1031
-            'options'       => $field->options,
1032
-            'required'      => $field->required,
1033
-            'field_key'     => $field->field_key,
1034
-            'field_order'   => $field->field_order,
1035
-            'form_id'       => $field->form_id,
1022
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1023
+
1024
+		$field_array = array(
1025
+			'id'            => $field->id,
1026
+			'value'         => $new_value,
1027
+			'default_value' => $field->default_value,
1028
+			'name'          => $field->name,
1029
+			'description'   => $field->description,
1030
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1031
+			'options'       => $field->options,
1032
+			'required'      => $field->required,
1033
+			'field_key'     => $field->field_key,
1034
+			'field_order'   => $field->field_order,
1035
+			'form_id'       => $field->form_id,
1036 1036
 			'parent_form_id' => $args['parent_form_id'],
1037
-        );
1037
+		);
1038 1038
 
1039
-        $args['field_type'] = $field_type;
1040
-        self::fill_field_opts($field, $field_array, $args);
1039
+		$args['field_type'] = $field_type;
1040
+		self::fill_field_opts($field, $field_array, $args);
1041 1041
 		// Track the original field's type
1042 1042
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1043 1043
 
1044
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1044
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1045 1045
 
1046
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1047
-            $field_array['unique_msg'] = '';
1048
-        }
1046
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1047
+			$field_array['unique_msg'] = '';
1048
+		}
1049 1049
 
1050
-        $field_array = array_merge( $field->field_options, $field_array );
1050
+		$field_array = array_merge( $field->field_options, $field_array );
1051 1051
 
1052
-        $values['fields'][ $field->id ] = $field_array;
1053
-    }
1052
+		$values['fields'][ $field->id ] = $field_array;
1053
+	}
1054 1054
 
1055 1055
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1056
-        $post_values = $args['post_values'];
1057
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1056
+		$post_values = $args['post_values'];
1057
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1058 1058
 
1059
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1059
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1060 1060
 			$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 );
1061
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1062
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1063
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1064
-                if ( $args['field_type'] == 'captcha' ) {
1065
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1066
-                } else {
1067
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1068
-                }
1069
-            }
1070
-        }
1071
-
1072
-        if ( $field_array['custom_html'] == '' ) {
1073
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1074
-        }
1075
-    }
1076
-
1077
-    /**
1078
-     * @param string $table
1079
-     */
1061
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1062
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1063
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1064
+				if ( $args['field_type'] == 'captcha' ) {
1065
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1066
+				} else {
1067
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1068
+				}
1069
+			}
1070
+		}
1071
+
1072
+		if ( $field_array['custom_html'] == '' ) {
1073
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1074
+		}
1075
+	}
1076
+
1077
+	/**
1078
+	 * @param string $table
1079
+	 */
1080 1080
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1081
-        if ( $table == 'entries' ) {
1082
-            $form = $record->form_id;
1081
+		if ( $table == 'entries' ) {
1082
+			$form = $record->form_id;
1083 1083
 			FrmForm::maybe_get_form( $form );
1084
-        } else {
1085
-            $form = $record;
1086
-        }
1084
+		} else {
1085
+			$form = $record;
1086
+		}
1087 1087
 
1088
-        if ( ! $form ) {
1089
-            return;
1090
-        }
1088
+		if ( ! $form ) {
1089
+			return;
1090
+		}
1091 1091
 
1092
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1092
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1093 1093
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1094 1094
 
1095
-        if ( ! is_array($form->options) ) {
1096
-            return;
1097
-        }
1095
+		if ( ! is_array($form->options) ) {
1096
+			return;
1097
+		}
1098 1098
 
1099
-        foreach ( $form->options as $opt => $value ) {
1100
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1101
-        }
1099
+		foreach ( $form->options as $opt => $value ) {
1100
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1101
+		}
1102 1102
 
1103
-        self::fill_form_defaults($post_values, $values);
1104
-    }
1103
+		self::fill_form_defaults($post_values, $values);
1104
+	}
1105 1105
 
1106
-    /**
1107
-     * Set to POST value or default
1108
-     */
1106
+	/**
1107
+	 * Set to POST value or default
1108
+	 */
1109 1109
 	private static function fill_form_defaults( $post_values, array &$values ) {
1110
-        $form_defaults = FrmFormsHelper::get_default_opts();
1110
+		$form_defaults = FrmFormsHelper::get_default_opts();
1111 1111
 
1112
-        foreach ( $form_defaults as $opt => $default ) {
1113
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1112
+		foreach ( $form_defaults as $opt => $default ) {
1113
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1114 1114
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1115
-            }
1115
+			}
1116 1116
 
1117
-            unset($opt, $defaut);
1118
-        }
1117
+			unset($opt, $defaut);
1118
+		}
1119 1119
 
1120
-        if ( ! isset($values['custom_style']) ) {
1121
-            $frm_settings = self::get_settings();
1120
+		if ( ! isset($values['custom_style']) ) {
1121
+			$frm_settings = self::get_settings();
1122 1122
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1123
-        }
1123
+		}
1124 1124
 
1125 1125
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1126 1126
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1127 1127
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1128
-            }
1129
-            unset($h);
1130
-        }
1131
-    }
1128
+			}
1129
+			unset($h);
1130
+		}
1131
+	}
1132 1132
 
1133 1133
 	public static function get_meta_value( $field_id, $entry ) {
1134 1134
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1136,59 +1136,59 @@  discard block
 block discarded – undo
1136 1136
 	}
1137 1137
 
1138 1138
 	public static function insert_opt_html( $args ) {
1139
-        $class = '';
1140
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1141
-            $class .= 'show_frm_not_email_to';
1142
-        }
1143
-    ?>
1139
+		$class = '';
1140
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1141
+			$class .= 'show_frm_not_email_to';
1142
+		}
1143
+	?>
1144 1144
 <li>
1145 1145
     <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>
1146 1146
     <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>
1147 1147
     <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>
1148 1148
 </li>
1149 1149
     <?php
1150
-    }
1150
+	}
1151 1151
 
1152 1152
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1153
-        if ( is_array( $str ) ) {
1154
-            return '';
1153
+		if ( is_array( $str ) ) {
1154
+			return '';
1155 1155
 		}
1156 1156
 
1157
-        $length = (int) $length;
1157
+		$length = (int) $length;
1158 1158
 		$str = wp_strip_all_tags( $str );
1159 1159
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1160 1160
 
1161 1161
 		if ( $length == 0 ) {
1162
-            return '';
1163
-        } else if ( $length <= 10 ) {
1162
+			return '';
1163
+		} else if ( $length <= 10 ) {
1164 1164
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1165
-            return $sub . (($length < $original_len) ? $continue : '');
1166
-        }
1165
+			return $sub . (($length < $original_len) ? $continue : '');
1166
+		}
1167 1167
 
1168
-        $sub = '';
1169
-        $len = 0;
1168
+		$sub = '';
1169
+		$len = 0;
1170 1170
 
1171 1171
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1172 1172
 
1173 1173
 		foreach ( $words as $word ) {
1174
-            $part = (($sub != '') ? ' ' : '') . $word;
1174
+			$part = (($sub != '') ? ' ' : '') . $word;
1175 1175
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1176
-            if ( $total_len > $length && str_word_count($sub) ) {
1177
-                break;
1178
-            }
1176
+			if ( $total_len > $length && str_word_count($sub) ) {
1177
+				break;
1178
+			}
1179 1179
 
1180
-            $sub .= $part;
1180
+			$sub .= $part;
1181 1181
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1182 1182
 
1183
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1184
-                break;
1185
-            }
1183
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1184
+				break;
1185
+			}
1186 1186
 
1187
-            unset($total_len, $word);
1188
-        }
1187
+			unset($total_len, $word);
1188
+		}
1189 1189
 
1190
-        return $sub . (($len < $original_len) ? $continue : '');
1191
-    }
1190
+		return $sub . (($len < $original_len) ? $continue : '');
1191
+	}
1192 1192
 
1193 1193
 	public static function mb_function( $function_names, $args ) {
1194 1194
 		$mb_function_name = $function_names[0];
@@ -1200,18 +1200,18 @@  discard block
 block discarded – undo
1200 1200
 	}
1201 1201
 
1202 1202
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1203
-        if ( empty($date) ) {
1204
-            return $date;
1205
-        }
1203
+		if ( empty($date) ) {
1204
+			return $date;
1205
+		}
1206 1206
 
1207
-        if ( empty($date_format) ) {
1208
-            $date_format = get_option('date_format');
1209
-        }
1207
+		if ( empty($date_format) ) {
1208
+			$date_format = get_option('date_format');
1209
+		}
1210 1210
 
1211
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1212
-            $frmpro_settings = new FrmProSettings();
1213
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1214
-        }
1211
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1212
+			$frmpro_settings = new FrmProSettings();
1213
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1214
+		}
1215 1215
 
1216 1216
 		$formatted = self::get_localized_date( $date_format, $date );
1217 1217
 
@@ -1220,8 +1220,8 @@  discard block
 block discarded – undo
1220 1220
 			$formatted .= self::add_time_to_date( $time_format, $date );
1221 1221
 		}
1222 1222
 
1223
-        return $formatted;
1224
-    }
1223
+		return $formatted;
1224
+	}
1225 1225
 
1226 1226
 	private static function add_time_to_date( $time_format, $date ) {
1227 1227
 		if ( empty( $time_format ) ) {
@@ -1302,61 +1302,61 @@  discard block
 block discarded – undo
1302 1302
 		);
1303 1303
 	}
1304 1304
 
1305
-    /**
1306
-     * Added for < WP 4.0 compatability
1307
-     *
1308
-     * @since 1.07.10
1309
-     *
1310
-     * @param string $term The value to escape
1311
-     * @return string The escaped value
1312
-     */
1305
+	/**
1306
+	 * Added for < WP 4.0 compatability
1307
+	 *
1308
+	 * @since 1.07.10
1309
+	 *
1310
+	 * @param string $term The value to escape
1311
+	 * @return string The escaped value
1312
+	 */
1313 1313
 	public static function esc_like( $term ) {
1314
-        global $wpdb;
1315
-        if ( method_exists($wpdb, 'esc_like') ) {
1314
+		global $wpdb;
1315
+		if ( method_exists($wpdb, 'esc_like') ) {
1316 1316
 			// WP 4.0
1317
-            $term = $wpdb->esc_like( $term );
1318
-        } else {
1319
-            $term = like_escape( $term );
1320
-        }
1317
+			$term = $wpdb->esc_like( $term );
1318
+		} else {
1319
+			$term = like_escape( $term );
1320
+		}
1321 1321
 
1322
-        return $term;
1323
-    }
1322
+		return $term;
1323
+	}
1324 1324
 
1325
-    /**
1326
-     * @param string $order_query
1327
-     */
1325
+	/**
1326
+	 * @param string $order_query
1327
+	 */
1328 1328
 	public static function esc_order( $order_query ) {
1329
-        if ( empty($order_query) ) {
1330
-            return '';
1331
-        }
1332
-
1333
-        // remove ORDER BY before santizing
1334
-        $order_query = strtolower($order_query);
1335
-        if ( strpos($order_query, 'order by') !== false ) {
1336
-            $order_query = str_replace('order by', '', $order_query);
1337
-        }
1338
-
1339
-        $order_query = explode(' ', trim($order_query));
1340
-
1341
-        $order_fields = array(
1342
-            'id', 'form_key', 'name', 'description',
1343
-            'parent_form_id', 'logged_in', 'is_template',
1344
-            'default_template', 'status', 'created_at',
1345
-        );
1346
-
1347
-        $order = trim(trim(reset($order_query), ','));
1348
-        if ( ! in_array($order, $order_fields) ) {
1349
-            return '';
1350
-        }
1351
-
1352
-        $order_by = '';
1353
-        if ( count($order_query) > 1 ) {
1329
+		if ( empty($order_query) ) {
1330
+			return '';
1331
+		}
1332
+
1333
+		// remove ORDER BY before santizing
1334
+		$order_query = strtolower($order_query);
1335
+		if ( strpos($order_query, 'order by') !== false ) {
1336
+			$order_query = str_replace('order by', '', $order_query);
1337
+		}
1338
+
1339
+		$order_query = explode(' ', trim($order_query));
1340
+
1341
+		$order_fields = array(
1342
+			'id', 'form_key', 'name', 'description',
1343
+			'parent_form_id', 'logged_in', 'is_template',
1344
+			'default_template', 'status', 'created_at',
1345
+		);
1346
+
1347
+		$order = trim(trim(reset($order_query), ','));
1348
+		if ( ! in_array($order, $order_fields) ) {
1349
+			return '';
1350
+		}
1351
+
1352
+		$order_by = '';
1353
+		if ( count($order_query) > 1 ) {
1354 1354
 			$order_by = end( $order_query );
1355 1355
 			self::esc_order_by( $order_by );
1356
-        }
1356
+		}
1357 1357
 
1358 1358
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1359
-    }
1359
+	}
1360 1360
 
1361 1361
 	/**
1362 1362
 	 * Make sure this is ordering by either ASC or DESC
@@ -1368,169 +1368,169 @@  discard block
 block discarded – undo
1368 1368
 		}
1369 1369
 	}
1370 1370
 
1371
-    /**
1372
-     * @param string $limit
1373
-     */
1371
+	/**
1372
+	 * @param string $limit
1373
+	 */
1374 1374
 	public static function esc_limit( $limit ) {
1375
-        if ( empty($limit) ) {
1376
-            return '';
1377
-        }
1375
+		if ( empty($limit) ) {
1376
+			return '';
1377
+		}
1378 1378
 
1379
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1380
-        if ( is_numeric($limit) ) {
1379
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1380
+		if ( is_numeric($limit) ) {
1381 1381
 			return ' LIMIT ' . $limit;
1382
-        }
1382
+		}
1383 1383
 
1384
-        $limit = explode(',', trim($limit));
1385
-        foreach ( $limit as $k => $l ) {
1386
-            if ( is_numeric( $l ) ) {
1387
-                $limit[ $k ] = $l;
1388
-            }
1389
-        }
1384
+		$limit = explode(',', trim($limit));
1385
+		foreach ( $limit as $k => $l ) {
1386
+			if ( is_numeric( $l ) ) {
1387
+				$limit[ $k ] = $l;
1388
+			}
1389
+		}
1390 1390
 
1391
-        $limit = implode(',', $limit);
1391
+		$limit = implode(',', $limit);
1392 1392
 		return ' LIMIT ' . $limit;
1393
-    }
1394
-
1395
-    /**
1396
-     * Get an array of values ready to go through $wpdb->prepare
1397
-     * @since 2.0
1398
-     */
1399
-    public static function prepare_array_values( $array, $type = '%s' ) {
1400
-        $placeholders = array_fill(0, count($array), $type);
1401
-        return implode(', ', $placeholders);
1402
-    }
1403
-
1404
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1405
-        if ( empty($where) ) {
1406
-            return '';
1407
-        }
1393
+	}
1394
+
1395
+	/**
1396
+	 * Get an array of values ready to go through $wpdb->prepare
1397
+	 * @since 2.0
1398
+	 */
1399
+	public static function prepare_array_values( $array, $type = '%s' ) {
1400
+		$placeholders = array_fill(0, count($array), $type);
1401
+		return implode(', ', $placeholders);
1402
+	}
1403
+
1404
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1405
+		if ( empty($where) ) {
1406
+			return '';
1407
+		}
1408 1408
 
1409 1409
 		if ( is_array( $where ) ) {
1410
-            global $wpdb;
1411
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1410
+			global $wpdb;
1411
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1412 1412
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1413 1413
 		} else {
1414
-            $where = $starts_with . $where;
1415
-        }
1414
+			$where = $starts_with . $where;
1415
+		}
1416 1416
 
1417
-        return $where;
1418
-    }
1417
+		return $where;
1418
+	}
1419 1419
 
1420
-    // Pagination Methods
1420
+	// Pagination Methods
1421 1421
 
1422
-    /**
1423
-     * @param integer $current_p
1424
-     */
1422
+	/**
1423
+	 * @param integer $current_p
1424
+	 */
1425 1425
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1426 1426
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1427 1427
 	}
1428 1428
 
1429
-    /**
1430
-     * @param integer $current_p
1431
-     */
1432
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1433
-        if ( $current_p == 1 ) {
1434
-            return 1;
1435
-        } else {
1436
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1437
-        }
1438
-    }
1429
+	/**
1430
+	 * @param integer $current_p
1431
+	 */
1432
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1433
+		if ( $current_p == 1 ) {
1434
+			return 1;
1435
+		} else {
1436
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1437
+		}
1438
+	}
1439 1439
 
1440 1440
 	/**
1441 1441
 	 * @return array
1442 1442
 	 */
1443 1443
 	public static function json_to_array( $json_vars ) {
1444
-        $vars = array();
1445
-        foreach ( $json_vars as $jv ) {
1446
-            $jv_name = explode('[', $jv['name']);
1447
-            $last = count($jv_name) - 1;
1448
-            foreach ( $jv_name as $p => $n ) {
1449
-                $name = trim($n, ']');
1450
-                if ( ! isset($l1) ) {
1451
-                    $l1 = $name;
1452
-                }
1453
-
1454
-                if ( ! isset($l2) ) {
1455
-                    $l2 = $name;
1456
-                }
1457
-
1458
-                if ( ! isset($l3) ) {
1459
-                    $l3 = $name;
1460
-                }
1461
-
1462
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1463
-
1464
-                switch ( $p ) {
1465
-                    case 0:
1466
-                        $l1 = $name;
1467
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1468
-                    break;
1469
-
1470
-                    case 1:
1471
-                        $l2 = $name;
1472
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1473
-                    break;
1474
-
1475
-                    case 2:
1476
-                        $l3 = $name;
1477
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1478
-                    break;
1479
-
1480
-                    case 3:
1481
-                        $l4 = $name;
1482
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1483
-                    break;
1484
-                }
1485
-
1486
-                unset($this_val, $n);
1487
-            }
1488
-
1489
-            unset($last, $jv);
1490
-        }
1491
-
1492
-        return $vars;
1493
-    }
1494
-
1495
-    /**
1496
-     * @param string $name
1497
-     * @param string $l1
1498
-     */
1499
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1500
-        if ( $name == '' ) {
1501
-            $vars[] = $val;
1502
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1503
-            $vars[ $l1 ] = $val;
1504
-        }
1505
-    }
1444
+		$vars = array();
1445
+		foreach ( $json_vars as $jv ) {
1446
+			$jv_name = explode('[', $jv['name']);
1447
+			$last = count($jv_name) - 1;
1448
+			foreach ( $jv_name as $p => $n ) {
1449
+				$name = trim($n, ']');
1450
+				if ( ! isset($l1) ) {
1451
+					$l1 = $name;
1452
+				}
1453
+
1454
+				if ( ! isset($l2) ) {
1455
+					$l2 = $name;
1456
+				}
1457
+
1458
+				if ( ! isset($l3) ) {
1459
+					$l3 = $name;
1460
+				}
1461
+
1462
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1463
+
1464
+				switch ( $p ) {
1465
+					case 0:
1466
+						$l1 = $name;
1467
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1468
+					break;
1469
+
1470
+					case 1:
1471
+						$l2 = $name;
1472
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1473
+					break;
1474
+
1475
+					case 2:
1476
+						$l3 = $name;
1477
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1478
+					break;
1479
+
1480
+					case 3:
1481
+						$l4 = $name;
1482
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1483
+					break;
1484
+				}
1485
+
1486
+				unset($this_val, $n);
1487
+			}
1488
+
1489
+			unset($last, $jv);
1490
+		}
1491
+
1492
+		return $vars;
1493
+	}
1494
+
1495
+	/**
1496
+	 * @param string $name
1497
+	 * @param string $l1
1498
+	 */
1499
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1500
+		if ( $name == '' ) {
1501
+			$vars[] = $val;
1502
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1503
+			$vars[ $l1 ] = $val;
1504
+		}
1505
+	}
1506 1506
 
1507 1507
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1508
-        $tooltips = array(
1509
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1510
-            'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1511
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1512
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1513
-            'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1514
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1515
-            '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() ) ),
1516
-        );
1517
-
1518
-        if ( ! isset( $tooltips[ $name ] ) ) {
1519
-            return;
1520
-        }
1521
-
1522
-        if ( 'open' == $class ) {
1523
-            echo ' frm_help"';
1524
-        } else {
1525
-            echo ' class="frm_help"';
1526
-        }
1508
+		$tooltips = array(
1509
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1510
+			'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1511
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1512
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1513
+			'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1514
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1515
+			'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() ) ),
1516
+		);
1517
+
1518
+		if ( ! isset( $tooltips[ $name ] ) ) {
1519
+			return;
1520
+		}
1521
+
1522
+		if ( 'open' == $class ) {
1523
+			echo ' frm_help"';
1524
+		} else {
1525
+			echo ' class="frm_help"';
1526
+		}
1527 1527
 
1528 1528
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1529 1529
 
1530
-        if ( 'open' != $class ) {
1531
-            echo '"';
1532
-        }
1533
-    }
1530
+		if ( 'open' != $class ) {
1531
+			echo '"';
1532
+		}
1533
+	}
1534 1534
 
1535 1535
 	/**
1536 1536
 	 * Add the current_page class to that page in the form nav
@@ -1546,35 +1546,35 @@  discard block
 block discarded – undo
1546 1546
 		}
1547 1547
 	}
1548 1548
 
1549
-    /**
1550
-     * Prepare and json_encode post content
1551
-     *
1552
-     * @since 2.0
1553
-     *
1554
-     * @param array $post_content
1555
-     * @return string $post_content ( json encoded array )
1556
-     */
1557
-    public static function prepare_and_encode( $post_content ) {
1558
-        //Loop through array to strip slashes and add only the needed ones
1549
+	/**
1550
+	 * Prepare and json_encode post content
1551
+	 *
1552
+	 * @since 2.0
1553
+	 *
1554
+	 * @param array $post_content
1555
+	 * @return string $post_content ( json encoded array )
1556
+	 */
1557
+	public static function prepare_and_encode( $post_content ) {
1558
+		//Loop through array to strip slashes and add only the needed ones
1559 1559
 		foreach ( $post_content as $key => $val ) {
1560 1560
 			// Replace problematic characters (like &quot;)
1561 1561
 			$val = str_replace( '&quot;', '"', $val );
1562 1562
 
1563 1563
 			self::prepare_action_slashes( $val, $key, $post_content );
1564
-            unset( $key, $val );
1565
-        }
1564
+			unset( $key, $val );
1565
+		}
1566 1566
 
1567
-        // json_encode the array
1568
-        $post_content = json_encode( $post_content );
1567
+		// json_encode the array
1568
+		$post_content = json_encode( $post_content );
1569 1569
 
1570
-	    // add extra slashes for \r\n since WP strips them
1570
+		// add extra slashes for \r\n since WP strips them
1571 1571
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1572 1572
 
1573
-        // allow for &quot
1574
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1573
+		// allow for &quot
1574
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1575 1575
 
1576
-        return $post_content;
1577
-    }
1576
+		return $post_content;
1577
+	}
1578 1578
 
1579 1579
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1580 1580
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1642,64 +1642,64 @@  discard block
 block discarded – undo
1642 1642
 	}
1643 1643
 
1644 1644
 	public static function maybe_json_decode( $string ) {
1645
-        if ( is_array($string) ) {
1646
-            return $string;
1647
-        }
1645
+		if ( is_array($string) ) {
1646
+			return $string;
1647
+		}
1648 1648
 
1649
-        $new_string = json_decode($string, true);
1650
-        if ( function_exists('json_last_error') ) {
1649
+		$new_string = json_decode($string, true);
1650
+		if ( function_exists('json_last_error') ) {
1651 1651
 			// php 5.3+
1652
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1653
-                $string = $new_string;
1654
-            }
1655
-        } else if ( isset($new_string) ) {
1652
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1653
+				$string = $new_string;
1654
+			}
1655
+		} else if ( isset($new_string) ) {
1656 1656
 			// php < 5.3 fallback
1657
-            $string = $new_string;
1658
-        }
1659
-        return $string;
1660
-    }
1661
-
1662
-    /**
1663
-     * @since 1.07.10
1664
-     *
1665
-     * @param string $post_type The name of the post type that may need to be highlighted
1666
-     * echo The javascript to open and highlight the Formidable menu
1667
-     */
1657
+			$string = $new_string;
1658
+		}
1659
+		return $string;
1660
+	}
1661
+
1662
+	/**
1663
+	 * @since 1.07.10
1664
+	 *
1665
+	 * @param string $post_type The name of the post type that may need to be highlighted
1666
+	 * echo The javascript to open and highlight the Formidable menu
1667
+	 */
1668 1668
 	public static function maybe_highlight_menu( $post_type ) {
1669
-        global $post;
1669
+		global $post;
1670 1670
 
1671
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1672
-            return;
1673
-        }
1671
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1672
+			return;
1673
+		}
1674 1674
 
1675
-        if ( is_object($post) && $post->post_type != $post_type ) {
1676
-            return;
1677
-        }
1675
+		if ( is_object($post) && $post->post_type != $post_type ) {
1676
+			return;
1677
+		}
1678 1678
 
1679
-        self::load_admin_wide_js();
1680
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1681
-    }
1679
+		self::load_admin_wide_js();
1680
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1681
+	}
1682 1682
 
1683
-    /**
1684
-     * Load the JS file on non-Formidable pages in the admin area
1685
-     * @since 2.0
1686
-     */
1683
+	/**
1684
+	 * Load the JS file on non-Formidable pages in the admin area
1685
+	 * @since 2.0
1686
+	 */
1687 1687
 	public static function load_admin_wide_js( $load = true ) {
1688
-        $version = FrmAppHelper::plugin_version();
1688
+		$version = FrmAppHelper::plugin_version();
1689 1689
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1690 1690
 
1691
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1691
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1692 1692
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1693
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1693
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1694 1694
 			'url'          => FrmAppHelper::plugin_url(),
1695 1695
 			'loading'      => __( 'Loading&hellip;' ),
1696 1696
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1697
-        ) );
1697
+		) );
1698 1698
 
1699 1699
 		if ( $load ) {
1700 1700
 			wp_enqueue_script( 'formidable_admin_global' );
1701 1701
 		}
1702
-    }
1702
+	}
1703 1703
 
1704 1704
 	/**
1705 1705
 	 * @since 2.0.9
@@ -1708,9 +1708,9 @@  discard block
 block discarded – undo
1708 1708
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1709 1709
 	}
1710 1710
 
1711
-    /**
1712
-     * @param string $location
1713
-     */
1711
+	/**
1712
+	 * @param string $location
1713
+	 */
1714 1714
 	public static function localize_script( $location ) {
1715 1715
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1716 1716
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1763,81 +1763,81 @@  discard block
 block discarded – undo
1763 1763
 		}
1764 1764
 	}
1765 1765
 
1766
-    /**
1766
+	/**
1767 1767
 	 * echo the message on the plugins listing page
1768
-     * @since 1.07.10
1769
-     *
1770
-     * @param float $min_version The version the add-on requires
1771
-     */
1768
+	 * @since 1.07.10
1769
+	 *
1770
+	 * @param float $min_version The version the add-on requires
1771
+	 */
1772 1772
 	public static function min_version_notice( $min_version ) {
1773
-        $frm_version = self::plugin_version();
1773
+		$frm_version = self::plugin_version();
1774 1774
 
1775
-        // check if Formidable meets minimum requirements
1776
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1777
-            return;
1778
-        }
1775
+		// check if Formidable meets minimum requirements
1776
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1777
+			return;
1778
+		}
1779 1779
 
1780
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1780
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1781 1781
 		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">' .
1782
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1783
-        '</div></td></tr>';
1784
-    }
1785
-
1786
-    public static function locales( $type = 'date' ) {
1787
-        $locales = array(
1788
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1789
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1790
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1791
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1792
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1793
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1794
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1795
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1796
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1797
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1798
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1799
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1800
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1801
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1802
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1803
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1804
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1805
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1806
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1807
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1808
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1809
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1810
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1811
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1812
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1813
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1814
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1815
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1816
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1817
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1818
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1819
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1820
-        );
1821
-
1822
-        if ( $type == 'captcha' ) {
1823
-            // remove the languages unavailable for the captcha
1824
-            $unset = array(
1825
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1826
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1827
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1828
-            );
1829
-        } else {
1830
-            // remove the languages unavailable for the datepicker
1831
-            $unset = array(
1832
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1833
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1834
-                'es-419', 'tr',
1835
-            );
1836
-        }
1837
-
1838
-        $locales = array_diff_key($locales, array_flip($unset));
1839
-        $locales = apply_filters('frm_locales', $locales);
1840
-
1841
-        return $locales;
1842
-    }
1782
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1783
+		'</div></td></tr>';
1784
+	}
1785
+
1786
+	public static function locales( $type = 'date' ) {
1787
+		$locales = array(
1788
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1789
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1790
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1791
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1792
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1793
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1794
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1795
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1796
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1797
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1798
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1799
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1800
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1801
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1802
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1803
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1804
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1805
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1806
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1807
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1808
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1809
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1810
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1811
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1812
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1813
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1814
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1815
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1816
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1817
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1818
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1819
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1820
+		);
1821
+
1822
+		if ( $type == 'captcha' ) {
1823
+			// remove the languages unavailable for the captcha
1824
+			$unset = array(
1825
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1826
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1827
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1828
+			);
1829
+		} else {
1830
+			// remove the languages unavailable for the datepicker
1831
+			$unset = array(
1832
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1833
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1834
+				'es-419', 'tr',
1835
+			);
1836
+		}
1837
+
1838
+		$locales = array_diff_key($locales, array_flip($unset));
1839
+		$locales = apply_filters('frm_locales', $locales);
1840
+
1841
+		return $locales;
1842
+	}
1843 1843
 }
Please login to merge, or discard this patch.
classes/models/FrmDb.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@
 block discarded – undo
308 308
 	 *
309 309
 	 * @since 2.02.05
310 310
 	 * @param string $key
311
-	 * @param int|string $value
311
+	 * @param string $value
312 312
 	 * @param string $where
313 313
 	 */
314 314
     private static function add_query_placeholder( $key, $value, &$where ) {
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
     var $entry_metas;
8 8
 
9 9
     public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
10
+        if ( ! defined( 'ABSPATH' ) ) {
11
+            die( 'You are not allowed to call this page directly.' );
12 12
         }
13 13
 
14 14
         global $wpdb;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $frm_db_version = FrmAppHelper::$db_version;
25 25
         $old_db_version = (float) $old_db_version;
26 26
         if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
27
+            $old_db_version = get_option( 'frm_db_version' );
28 28
         }
29 29
 
30 30
         if ( $frm_db_version != $old_db_version ) {
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36 36
             $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
37
+            $this->migrate_data( $frm_db_version, $old_db_version );
38 38
 
39 39
             /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
40
+            update_option( 'frm_db_version', $frm_db_version );
41 41
 
42 42
             /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43 43
             FrmXMLController::add_default_templates();
44 44
         }
45 45
 
46
-        do_action('frm_after_install');
46
+        do_action( 'frm_after_install' );
47 47
 
48 48
         /**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
156
+            unset( $q );
157 157
         }
158 158
     }
159 159
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @param string $starts_with
179 179
      */
180 180
     public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
181
-        if ( empty($args) ) {
181
+        if ( empty( $args ) ) {
182 182
 			// add an arg to prevent prepare from failing
183 183
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
184 184
 			return;
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
     private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
239 239
 		$key = trim( $key );
240 240
 
241
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
242
-            $k = explode(' ', $key);
241
+        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
242
+            $k = explode( ' ', $key );
243 243
             $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
244 244
             $values[] = '%Y-%m-%d %H:%i:%s';
245 245
         } else {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         if ( is_array( $value ) ) {
253 253
             // translate array of values to "in"
254 254
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
255
-				$where = preg_replace('/' . $key . '$/', '', $where);
255
+				$where = preg_replace( '/' . $key . '$/', '', $where );
256 256
 				$where .= '(';
257 257
 				$start = true;
258 258
 				foreach ( $value as $v ) {
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 		);
404 404
 
405 405
 		$where_is = strtolower( $where_is );
406
-		if ( isset( $switch_to[ $where_is ] ) ) {
407
-			return ' ' . $switch_to[ $where_is ];
406
+		if ( isset( $switch_to[$where_is] ) ) {
407
+			return ' ' . $switch_to[$where_is];
408 408
 		}
409 409
 
410 410
 		// > and < need a little more work since we don't want them switched to >= and <=
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
     private static function get_group_and_table_name( &$table, &$group ) {
427 427
 		global $wpdb, $wpmuBaseTablePrefix;
428 428
 
429
-        $table_parts = explode(' ', $table);
430
-        $group = reset($table_parts);
429
+        $table_parts = explode( ' ', $table );
430
+        $group = reset( $table_parts );
431 431
         $group = str_replace( $wpdb->prefix, '', $group );
432 432
 
433 433
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     }
443 443
 
444 444
     private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
445
-        if ( ! is_array($args) ) {
445
+        if ( ! is_array( $args ) ) {
446 446
 			$args = array( 'order_by' => $args );
447 447
         }
448 448
 
@@ -457,16 +457,16 @@  discard block
 block discarded – undo
457 457
         $temp_args = $args;
458 458
         foreach ( $temp_args as $k => $v ) {
459 459
             if ( $v == '' ) {
460
-				unset( $args[ $k ] );
460
+				unset( $args[$k] );
461 461
                 continue;
462 462
             }
463 463
 
464 464
             if ( $k == 'limit' ) {
465
-				$args[ $k ] = FrmAppHelper::esc_limit( $v );
465
+				$args[$k] = FrmAppHelper::esc_limit( $v );
466 466
             }
467 467
             $db_name = strtoupper( str_replace( '_', ' ', $k ) );
468 468
             if ( strpos( $v, $db_name ) === false ) {
469
-				$args[ $k ] = $db_name . ' ' . $v;
469
+				$args[$k] = $db_name . ' ' . $v;
470 470
             }
471 471
         }
472 472
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 
494 494
 		$query = self::generate_query_string_from_pieces( $columns, $table, $where );
495 495
 
496
-		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A' , ' WHERE' ) );
496
+		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) );
497 497
 		$results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_associative_results' );
498 498
 
499 499
 		return $results;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     public function uninstall() {
533 533
 		if ( ! current_user_can( 'administrator' ) ) {
534 534
             $frm_settings = FrmAppHelper::get_settings();
535
-            wp_die($frm_settings->admin_permission);
535
+            wp_die( $frm_settings->admin_permission );
536 536
         }
537 537
 
538 538
         global $wpdb, $wp_roles;
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
543 543
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
544 544
 
545
-        delete_option('frm_options');
546
-        delete_option('frm_db_version');
545
+        delete_option( 'frm_options' );
546
+        delete_option( 'frm_db_version' );
547 547
 
548 548
         //delete roles
549 549
         $frm_roles = FrmAppHelper::frm_capabilities();
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
552 552
             foreach ( $roles as $role => $details ) {
553 553
                 $wp_roles->remove_cap( $role, $frm_role );
554
-                unset($role, $details);
554
+                unset( $role, $details );
555 555
     		}
556
-    		unset($frm_role, $frm_role_description);
556
+    		unset( $frm_role, $frm_role_description );
557 557
 		}
558
-		unset($roles, $frm_roles);
558
+		unset( $roles, $frm_roles );
559 559
 
560 560
 		// delete actions, views, and styles
561 561
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 
578 578
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
579 579
 
580
-        do_action('frm_after_uninstall');
580
+        do_action( 'frm_after_uninstall' );
581 581
         return true;
582 582
     }
583 583
 
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
 
635 635
         $updated = 0;
636 636
         foreach ( $fields as $f ) {
637
-            $f->field_options = maybe_unserialize($f->field_options);
638
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
637
+            $f->field_options = maybe_unserialize( $f->field_options );
638
+            if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
639 639
                 continue;
640 640
             }
641 641
 
@@ -643,27 +643,27 @@  discard block
 block discarded – undo
643 643
             $f->field_options['size'] .= 'px';
644 644
             $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
645 645
             if ( $u ) {
646
-                $updated++;
646
+                $updated ++;
647 647
             }
648
-            unset($f);
648
+            unset( $f );
649 649
         }
650 650
 
651 651
         // Change the characters in widgets to pixels
652
-        $widgets = get_option('widget_frm_show_form');
653
-        if ( empty($widgets) ) {
652
+        $widgets = get_option( 'widget_frm_show_form' );
653
+        if ( empty( $widgets ) ) {
654 654
             return;
655 655
         }
656 656
 
657
-        $widgets = maybe_unserialize($widgets);
657
+        $widgets = maybe_unserialize( $widgets );
658 658
         foreach ( $widgets as $k => $widget ) {
659
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
659
+            if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
660 660
                 continue;
661 661
             }
662 662
 			$size = round( $pixel_conversion * (int) $widget['size'] );
663 663
             $size .= 'px';
664
-			$widgets[ $k ]['size'] = $size;
664
+			$widgets[$k]['size'] = $size;
665 665
         }
666
-        update_option('widget_frm_show_form', $widgets);
666
+        update_option( 'widget_frm_show_form', $widgets );
667 667
     }
668 668
 
669 669
     /**
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			}
713 713
 
714 714
             // Format form options
715
-            $form_options = maybe_unserialize($form->options);
715
+            $form_options = maybe_unserialize( $form->options );
716 716
 
717 717
             // Migrate settings to actions
718 718
             FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
     private function migrate_to_11() {
723 723
         global $wpdb;
724 724
 
725
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
725
+        $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
726 726
 
727 727
         $sending = __( 'Sending', 'formidable' );
728 728
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
734 734
 </div>
735 735
 DEFAULT_HTML;
736
-        unset($sending, $img);
736
+        unset( $sending, $img );
737 737
 
738
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
738
+        $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
739 739
         $draft_link = FrmFormsHelper::get_draft_link();
740 740
 		foreach ( $forms as $form ) {
741
-            $form->options = maybe_unserialize($form->options);
742
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
741
+            $form->options = maybe_unserialize( $form->options );
742
+            if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
743 743
                 continue;
744 744
             }
745 745
 
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
751 751
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
752 752
             }
753
-            unset($form);
753
+            unset( $form );
754 754
         }
755
-        unset($forms);
755
+        unset( $forms );
756 756
     }
757 757
 
758 758
     private function migrate_to_6() {
@@ -781,16 +781,16 @@  discard block
 block discarded – undo
781 781
 </div>
782 782
 DEFAULT_HTML;
783 783
 
784
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
784
+        $new_default_html = FrmFieldsHelper::get_default_html( 'text' );
785 785
         foreach ( $fields as $field ) {
786
-            $field->field_options = maybe_unserialize($field->field_options);
786
+            $field->field_options = maybe_unserialize( $field->field_options );
787 787
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
788 788
                 $field->field_options['custom_html'] = $new_default_html;
789 789
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
790 790
             }
791
-            unset($field);
791
+            unset( $field );
792 792
         }
793
-        unset($default_html, $old_default_html, $fields);
793
+        unset( $default_html, $old_default_html, $fields );
794 794
     }
795 795
 
796 796
     private function migrate_to_4() {
@@ -808,6 +808,6 @@  discard block
 block discarded – undo
808 808
 
809 809
 	public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
810 810
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
811
-		return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
811
+		return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) );
812 812
 	}
813 813
 }
Please login to merge, or discard this patch.
Indentation   +338 added lines, -338 removed lines patch added patch discarded remove patch
@@ -1,64 +1,64 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmDb {
4
-    var $fields;
5
-    var $forms;
6
-    var $entries;
7
-    var $entry_metas;
8
-
9
-    public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
12
-        }
13
-
14
-        global $wpdb;
15
-        $this->fields         = $wpdb->prefix . 'frm_fields';
16
-        $this->forms          = $wpdb->prefix . 'frm_forms';
17
-        $this->entries        = $wpdb->prefix . 'frm_items';
18
-        $this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
-    }
20
-
21
-    public function upgrade( $old_db_version = false ) {
22
-        global $wpdb;
23
-        //$frm_db_version is the version of the database we're moving to
24
-        $frm_db_version = FrmAppHelper::$db_version;
25
-        $old_db_version = (float) $old_db_version;
26
-        if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
28
-        }
29
-
30
-        if ( $frm_db_version != $old_db_version ) {
4
+	var $fields;
5
+	var $forms;
6
+	var $entries;
7
+	var $entry_metas;
8
+
9
+	public function __construct() {
10
+		if ( ! defined('ABSPATH') ) {
11
+			die('You are not allowed to call this page directly.');
12
+		}
13
+
14
+		global $wpdb;
15
+		$this->fields         = $wpdb->prefix . 'frm_fields';
16
+		$this->forms          = $wpdb->prefix . 'frm_forms';
17
+		$this->entries        = $wpdb->prefix . 'frm_items';
18
+		$this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
+	}
20
+
21
+	public function upgrade( $old_db_version = false ) {
22
+		global $wpdb;
23
+		//$frm_db_version is the version of the database we're moving to
24
+		$frm_db_version = FrmAppHelper::$db_version;
25
+		$old_db_version = (float) $old_db_version;
26
+		if ( ! $old_db_version ) {
27
+			$old_db_version = get_option('frm_db_version');
28
+		}
29
+
30
+		if ( $frm_db_version != $old_db_version ) {
31 31
 			// update rewrite rules for views and other custom post types
32 32
 			flush_rewrite_rules();
33 33
 
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36
-            $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
36
+			$this->create_tables();
37
+			$this->migrate_data($frm_db_version, $old_db_version);
38 38
 
39
-            /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
39
+			/***** SAVE DB VERSION *****/
40
+			update_option('frm_db_version', $frm_db_version);
41 41
 
42
-            /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43
-            FrmXMLController::add_default_templates();
44
-        }
42
+			/**** ADD/UPDATE DEFAULT TEMPLATES ****/
43
+			FrmXMLController::add_default_templates();
44
+		}
45 45
 
46
-        do_action('frm_after_install');
46
+		do_action('frm_after_install');
47 47
 
48
-        /**** update the styling settings ****/
48
+		/**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
50 50
 			$frm_style = new FrmStyle();
51 51
 			$frm_style->update( 'default' );
52 52
 		}
53
-    }
53
+	}
54 54
 
55
-    public function collation() {
56
-        global $wpdb;
57
-        if ( ! $wpdb->has_cap( 'collation' ) ) {
58
-            return '';
59
-        }
55
+	public function collation() {
56
+		global $wpdb;
57
+		if ( ! $wpdb->has_cap( 'collation' ) ) {
58
+			return '';
59
+		}
60 60
 
61
-        $charset_collate = '';
61
+		$charset_collate = '';
62 62
 		if ( ! empty( $wpdb->charset ) ) {
63 63
 			$charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset;
64 64
 		}
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 			$charset_collate .= ' COLLATE ' . $wpdb->collate;
68 68
 		}
69 69
 
70
-        return $charset_collate;
71
-    }
70
+		return $charset_collate;
71
+	}
72 72
 
73
-    private function create_tables() {
74
-        $charset_collate = $this->collation();
75
-        $sql = array();
73
+	private function create_tables() {
74
+		$charset_collate = $this->collation();
75
+		$sql = array();
76 76
 
77
-        /* Create/Upgrade Fields Table */
77
+		/* Create/Upgrade Fields Table */
78 78
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
79 79
                 id int(11) NOT NULL auto_increment,
80 80
 				field_key varchar(100) default NULL,
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                 UNIQUE KEY field_key (field_key)
94 94
         )';
95 95
 
96
-        /* Create/Upgrade Forms Table */
96
+		/* Create/Upgrade Forms Table */
97 97
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
98 98
                 id int(11) NOT NULL auto_increment,
99 99
 				form_key varchar(100) default NULL,
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                 UNIQUE KEY form_key (form_key)
112 112
         )';
113 113
 
114
-        /* Create/Upgrade Items Table */
114
+		/* Create/Upgrade Items Table */
115 115
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
116 116
                 id int(11) NOT NULL auto_increment,
117 117
 				item_key varchar(100) default NULL,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 UNIQUE KEY item_key (item_key)
135 135
         )';
136 136
 
137
-        /* Create/Upgrade Meta Table */
137
+		/* Create/Upgrade Meta Table */
138 138
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
139 139
                 id int(11) NOT NULL auto_increment,
140 140
                 meta_value longtext default NULL,
@@ -146,43 +146,43 @@  discard block
 block discarded – undo
146 146
                 KEY item_id (item_id)
147 147
         )';
148 148
 
149
-        foreach ( $sql as $q ) {
149
+		foreach ( $sql as $q ) {
150 150
 			if ( function_exists( 'dbDelta' ) ) {
151 151
 				dbDelta( $q . $charset_collate . ';' );
152 152
 			} else {
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
157
-        }
158
-    }
156
+			unset($q);
157
+		}
158
+	}
159 159
 
160
-    /**
161
-     * @param integer $frm_db_version
160
+	/**
161
+	 * @param integer $frm_db_version
162 162
 	 * @param int $old_db_version
163
-     */
163
+	 */
164 164
 	private function migrate_data( $frm_db_version, $old_db_version ) {
165 165
 		$migrations = array( 4, 6, 11, 16, 17, 23, 25 );
166
-        foreach ( $migrations as $migration ) {
167
-            if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
166
+		foreach ( $migrations as $migration ) {
167
+			if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
168 168
 				$function_name = 'migrate_to_' . $migration;
169
-                $this->$function_name();
170
-            }
171
-        }
172
-    }
169
+				$this->$function_name();
170
+			}
171
+		}
172
+	}
173 173
 
174
-    /**
175
-     * Change array into format $wpdb->prepare can use
174
+	/**
175
+	 * Change array into format $wpdb->prepare can use
176 176
 	 *
177 177
 	 * @param array $args
178 178
 	 * @param string $starts_with
179
-     */
180
-    public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
181
-        if ( empty($args) ) {
179
+	 */
180
+	public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
181
+		if ( empty($args) ) {
182 182
 			// add an arg to prevent prepare from failing
183 183
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
184 184
 			return;
185
-        }
185
+		}
186 186
 
187 187
 		$where = '';
188 188
 		$values = array();
@@ -193,64 +193,64 @@  discard block
 block discarded – undo
193 193
 		}
194 194
 
195 195
 		$args = compact( 'where', 'values' );
196
-    }
196
+	}
197 197
 
198
-    /**
198
+	/**
199 199
 	 * @param array $args
200
-     * @param string $base_where
201
-     * @param string $where
200
+	 * @param string $base_where
201
+	 * @param string $where
202 202
 	 * @param array $values
203
-     */
204
-    public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
205
-        $condition = ' AND';
206
-        if ( isset( $args['or'] ) ) {
207
-            $condition = ' OR';
208
-            unset( $args['or'] );
209
-        }
210
-
211
-        foreach ( $args as $key => $value ) {
212
-            $where .= empty( $where ) ? $base_where : $condition;
213
-            $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
214
-            if ( is_numeric( $key ) || $array_inc_null ) {
215
-                $where .= ' ( ';
216
-                $nested_where = '';
217
-                if ( $array_inc_null ) {
218
-                    foreach ( $value as $val ) {
219
-                        self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
220
-                    }
221
-                } else {
222
-                    self::parse_where_from_array( $value, '', $nested_where, $values );
223
-                }
224
-                $where .= $nested_where;
225
-                $where .= ' ) ';
226
-            } else {
227
-                self::interpret_array_to_sql( $key, $value, $where, $values );
228
-            }
229
-        }
230
-    }
231
-
232
-    /**
233
-     * @param string $key
203
+	 */
204
+	public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
205
+		$condition = ' AND';
206
+		if ( isset( $args['or'] ) ) {
207
+			$condition = ' OR';
208
+			unset( $args['or'] );
209
+		}
210
+
211
+		foreach ( $args as $key => $value ) {
212
+			$where .= empty( $where ) ? $base_where : $condition;
213
+			$array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
214
+			if ( is_numeric( $key ) || $array_inc_null ) {
215
+				$where .= ' ( ';
216
+				$nested_where = '';
217
+				if ( $array_inc_null ) {
218
+					foreach ( $value as $val ) {
219
+						self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
220
+					}
221
+				} else {
222
+					self::parse_where_from_array( $value, '', $nested_where, $values );
223
+				}
224
+				$where .= $nested_where;
225
+				$where .= ' ) ';
226
+			} else {
227
+				self::interpret_array_to_sql( $key, $value, $where, $values );
228
+			}
229
+		}
230
+	}
231
+
232
+	/**
233
+	 * @param string $key
234 234
 	 * @param string|array $value
235
-     * @param string $where
235
+	 * @param string $where
236 236
 	 * @param array $values
237
-     */
238
-    private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
237
+	 */
238
+	private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
239 239
 		$key = trim( $key );
240 240
 
241
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
242
-            $k = explode(' ', $key);
243
-            $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
244
-            $values[] = '%Y-%m-%d %H:%i:%s';
245
-        } else {
241
+		if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
242
+			$k = explode(' ', $key);
243
+			$where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
244
+			$values[] = '%Y-%m-%d %H:%i:%s';
245
+		} else {
246 246
 			$where .= ' ' . $key;
247
-        }
247
+		}
248 248
 
249 249
 		$lowercase_key = explode( ' ', strtolower( $key ) );
250 250
 		$lowercase_key = end( $lowercase_key );
251 251
 
252
-        if ( is_array( $value ) ) {
253
-            // translate array of values to "in"
252
+		if ( is_array( $value ) ) {
253
+			// translate array of values to "in"
254 254
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
255 255
 				$where = preg_replace('/' . $key . '$/', '', $where);
256 256
 				$where .= '(';
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 				$where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')';
269 269
 				$values = array_merge( $values, $value );
270 270
 			}
271
-        } else if ( strpos( $lowercase_key, 'like' ) !== false ) {
271
+		} else if ( strpos( $lowercase_key, 'like' ) !== false ) {
272 272
 			/**
273 273
 			 * Allow string to start or end with the value
274 274
 			 * If the key is like% then skip the first % for starts with
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 			$where .= ' %s';
288 288
 			$values[] = $start . FrmAppHelper::esc_like( $value ) . $end;
289 289
 
290
-        } else if ( $value === null ) {
291
-            $where .= ' IS NULL';
292
-        } else {
290
+		} else if ( $value === null ) {
291
+			$where .= ' IS NULL';
292
+		} else {
293 293
 			// allow a - to prevent = from being added
294 294
 			if ( substr( $key, -1 ) == '-' ) {
295 295
 				$where = rtrim( $where, '-' );
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 
300 300
 			self::add_query_placeholder( $key, $value, $where );
301 301
 
302
-            $values[] = $value;
303
-        }
304
-    }
302
+			$values[] = $value;
303
+		}
304
+	}
305 305
 
306 306
 	/**
307 307
 	 * Add %d, or %s to query
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 * @param int|string $value
312 312
 	 * @param string $where
313 313
 	 */
314
-    private static function add_query_placeholder( $key, $value, &$where ) {
314
+	private static function add_query_placeholder( $key, $value, &$where ) {
315 315
 		if ( is_numeric( $value ) && strpos( $key, 'meta_value' ) === false ) {
316 316
 			$where .= '%d';
317 317
 		} else {
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
 		}
320 320
 	}
321 321
 
322
-    /**
323
-     * @param string $table
322
+	/**
323
+	 * @param string $table
324 324
 	 * @param array $where
325 325
 	 * @param array $args
326 326
 	 * @return int
327
-     */
328
-    public static function get_count( $table, $where = array(), $args = array() ) {
329
-        $count = self::get_var( $table, $where, 'COUNT(*)', $args );
330
-        return $count;
331
-    }
327
+	 */
328
+	public static function get_count( $table, $where = array(), $args = array() ) {
329
+		$count = self::get_var( $table, $where, 'COUNT(*)', $args );
330
+		return $count;
331
+	}
332 332
 
333 333
 	/**
334 334
 	 * @param string $table
@@ -339,56 +339,56 @@  discard block
 block discarded – undo
339 339
 	 * @param string $type
340 340
 	 * @return array|null|string|object
341 341
 	 */
342
-    public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
343
-        $group = '';
344
-        self::get_group_and_table_name( $table, $group );
342
+	public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
343
+		$group = '';
344
+		self::get_group_and_table_name( $table, $group );
345 345
 		self::convert_options_to_array( $args, '', $limit );
346 346
 
347 347
 		$query = self::generate_query_string_from_pieces( $field, $table, $where, $args );
348 348
 
349 349
 		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) );
350 350
 		$results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type );
351
-        return $results;
352
-    }
351
+		return $results;
352
+	}
353 353
 
354
-    /**
355
-     * @param string $table
356
-     * @param array $where
354
+	/**
355
+	 * @param string $table
356
+	 * @param array $where
357 357
 	 * @param string $field
358 358
 	 * @param array $args
359 359
 	 * @param string $limit
360 360
 	 * @return mixed
361
-     */
362
-    public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
363
-        return self::get_var( $table, $where, $field, $args, $limit, 'col' );
364
-    }
365
-
366
-    /**
367
-     * @since 2.0
368
-     * @param string $table
361
+	 */
362
+	public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
363
+		return self::get_var( $table, $where, $field, $args, $limit, 'col' );
364
+	}
365
+
366
+	/**
367
+	 * @since 2.0
368
+	 * @param string $table
369 369
 	 * @param array $where
370 370
 	 * @param string $fields
371 371
 	 * @param array $args
372 372
 	 * @return mixed
373
-     */
374
-    public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
375
-        $args['limit'] = 1;
376
-        return self::get_var( $table, $where, $fields, $args, '', 'row' );
377
-    }
378
-
379
-    /**
380
-     * Prepare a key/value array before DB call
373
+	 */
374
+	public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
375
+		$args['limit'] = 1;
376
+		return self::get_var( $table, $where, $fields, $args, '', 'row' );
377
+	}
378
+
379
+	/**
380
+	 * Prepare a key/value array before DB call
381 381
 	 *
382
-     * @since 2.0
383
-     * @param string $table
382
+	 * @since 2.0
383
+	 * @param string $table
384 384
 	 * @param array $where
385 385
 	 * @param string $fields
386 386
 	 * @param array $args
387 387
 	 * @return mixed
388
-     */
389
-    public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
390
-        return self::get_var( $table, $where, $fields, $args, '', 'results' );
391
-    }
388
+	 */
389
+	public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
390
+		return self::get_var( $table, $where, $fields, $args, '', 'results' );
391
+	}
392 392
 
393 393
 	/**
394 394
 	 * Check for like, not like, in, not in, =, !=, >, <, <=, >=
@@ -425,59 +425,59 @@  discard block
 block discarded – undo
425 425
 		return '';
426 426
 	}
427 427
 
428
-    /**
429
-     * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
430
-     * Also add the wpdb->prefix to the table if it's missing
431
-     *
432
-     * @param string $table
433
-     * @param string $group
434
-     */
435
-    private static function get_group_and_table_name( &$table, &$group ) {
428
+	/**
429
+	 * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
430
+	 * Also add the wpdb->prefix to the table if it's missing
431
+	 *
432
+	 * @param string $table
433
+	 * @param string $group
434
+	 */
435
+	private static function get_group_and_table_name( &$table, &$group ) {
436 436
 		global $wpdb, $wpmuBaseTablePrefix;
437 437
 
438
-        $table_parts = explode(' ', $table);
439
-        $group = reset($table_parts);
440
-        $group = str_replace( $wpdb->prefix, '', $group );
438
+		$table_parts = explode(' ', $table);
439
+		$group = reset($table_parts);
440
+		$group = str_replace( $wpdb->prefix, '', $group );
441 441
 
442 442
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
443 443
 		$group = str_replace( $prefix, '', $group );
444 444
 
445
-        if ( $group == $table ) {
446
-            $table = $wpdb->prefix . $table;
447
-        }
445
+		if ( $group == $table ) {
446
+			$table = $wpdb->prefix . $table;
447
+		}
448 448
 
449 449
 		// switch to singular group name
450 450
 		$group = rtrim( $group, 's' );
451
-    }
451
+	}
452 452
 
453
-    private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
454
-        if ( ! is_array($args) ) {
453
+	private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
454
+		if ( ! is_array($args) ) {
455 455
 			$args = array( 'order_by' => $args );
456
-        }
456
+		}
457 457
 
458
-        if ( ! empty( $order_by ) ) {
459
-            $args['order_by'] = $order_by;
460
-        }
458
+		if ( ! empty( $order_by ) ) {
459
+			$args['order_by'] = $order_by;
460
+		}
461 461
 
462
-        if ( ! empty( $limit ) ) {
463
-            $args['limit'] = $limit;
464
-        }
462
+		if ( ! empty( $limit ) ) {
463
+			$args['limit'] = $limit;
464
+		}
465 465
 
466
-        $temp_args = $args;
467
-        foreach ( $temp_args as $k => $v ) {
468
-            if ( $v == '' ) {
466
+		$temp_args = $args;
467
+		foreach ( $temp_args as $k => $v ) {
468
+			if ( $v == '' ) {
469 469
 				unset( $args[ $k ] );
470
-                continue;
471
-            }
470
+				continue;
471
+			}
472 472
 
473
-            if ( $k == 'limit' ) {
473
+			if ( $k == 'limit' ) {
474 474
 				$args[ $k ] = FrmAppHelper::esc_limit( $v );
475
-            }
476
-            $db_name = strtoupper( str_replace( '_', ' ', $k ) );
477
-            if ( strpos( $v, $db_name ) === false ) {
475
+			}
476
+			$db_name = strtoupper( str_replace( '_', ' ', $k ) );
477
+			if ( strpos( $v, $db_name ) === false ) {
478 478
 				$args[ $k ] = $db_name . ' ' . $v;
479
-            }
480
-        }
479
+			}
480
+		}
481 481
 
482 482
 		// Make sure LIMIT is the last argument
483 483
 		if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) {
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 			unset( $args['limit'] );
486 486
 			$args['limit'] = $temp_limit;
487 487
 		}
488
-    }
488
+	}
489 489
 
490 490
 	/**
491 491
 	 * Get the associative array results for the given columns, table, and where query
@@ -538,31 +538,31 @@  discard block
 block discarded – undo
538 538
 		return $query;
539 539
 	}
540 540
 
541
-    public function uninstall() {
541
+	public function uninstall() {
542 542
 		if ( ! current_user_can( 'administrator' ) ) {
543
-            $frm_settings = FrmAppHelper::get_settings();
544
-            wp_die($frm_settings->admin_permission);
545
-        }
543
+			$frm_settings = FrmAppHelper::get_settings();
544
+			wp_die($frm_settings->admin_permission);
545
+		}
546 546
 
547
-        global $wpdb, $wp_roles;
547
+		global $wpdb, $wp_roles;
548 548
 
549 549
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields );
550 550
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms );
551 551
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
552 552
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
553 553
 
554
-        delete_option('frm_options');
555
-        delete_option('frm_db_version');
554
+		delete_option('frm_options');
555
+		delete_option('frm_db_version');
556 556
 
557
-        //delete roles
558
-        $frm_roles = FrmAppHelper::frm_capabilities();
559
-        $roles = get_editable_roles();
560
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
561
-            foreach ( $roles as $role => $details ) {
562
-                $wp_roles->remove_cap( $role, $frm_role );
563
-                unset($role, $details);
564
-    		}
565
-    		unset($frm_role, $frm_role_description);
557
+		//delete roles
558
+		$frm_roles = FrmAppHelper::frm_capabilities();
559
+		$roles = get_editable_roles();
560
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
561
+			foreach ( $roles as $role => $details ) {
562
+				$wp_roles->remove_cap( $role, $frm_role );
563
+				unset($role, $details);
564
+			}
565
+			unset($frm_role, $frm_role_description);
566 566
 		}
567 567
 		unset($roles, $frm_roles);
568 568
 
@@ -586,9 +586,9 @@  discard block
 block discarded – undo
586 586
 
587 587
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
588 588
 
589
-        do_action('frm_after_uninstall');
590
-        return true;
591
-    }
589
+		do_action('frm_after_uninstall');
590
+		return true;
591
+	}
592 592
 
593 593
 	/**
594 594
 	 * Migrate old styling settings. If sites are using the old
@@ -627,150 +627,150 @@  discard block
 block discarded – undo
627 627
 		}
628 628
 	}
629 629
 
630
-    /**
631
-     * Change field size from character to pixel -- Multiply by 9
632
-     */
633
-    private function migrate_to_17() {
634
-        global $wpdb;
630
+	/**
631
+	 * Change field size from character to pixel -- Multiply by 9
632
+	 */
633
+	private function migrate_to_17() {
634
+		global $wpdb;
635 635
 		$pixel_conversion = 9;
636 636
 
637
-        // Get query arguments
637
+		// Get query arguments
638 638
 		$field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' );
639 639
 		$query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' );
640 640
 
641
-        // Get results
641
+		// Get results
642 642
 		$fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' );
643 643
 
644
-        $updated = 0;
645
-        foreach ( $fields as $f ) {
646
-            $f->field_options = maybe_unserialize($f->field_options);
647
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
648
-                continue;
649
-            }
644
+		$updated = 0;
645
+		foreach ( $fields as $f ) {
646
+			$f->field_options = maybe_unserialize($f->field_options);
647
+			if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
648
+				continue;
649
+			}
650 650
 
651 651
 			$f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] );
652
-            $f->field_options['size'] .= 'px';
653
-            $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
654
-            if ( $u ) {
655
-                $updated++;
656
-            }
657
-            unset($f);
658
-        }
659
-
660
-        // Change the characters in widgets to pixels
661
-        $widgets = get_option('widget_frm_show_form');
662
-        if ( empty($widgets) ) {
663
-            return;
664
-        }
665
-
666
-        $widgets = maybe_unserialize($widgets);
667
-        foreach ( $widgets as $k => $widget ) {
668
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
669
-                continue;
670
-            }
652
+			$f->field_options['size'] .= 'px';
653
+			$u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
654
+			if ( $u ) {
655
+				$updated++;
656
+			}
657
+			unset($f);
658
+		}
659
+
660
+		// Change the characters in widgets to pixels
661
+		$widgets = get_option('widget_frm_show_form');
662
+		if ( empty($widgets) ) {
663
+			return;
664
+		}
665
+
666
+		$widgets = maybe_unserialize($widgets);
667
+		foreach ( $widgets as $k => $widget ) {
668
+			if ( ! is_array($widget) || ! isset($widget['size']) ) {
669
+				continue;
670
+			}
671 671
 			$size = round( $pixel_conversion * (int) $widget['size'] );
672
-            $size .= 'px';
672
+			$size .= 'px';
673 673
 			$widgets[ $k ]['size'] = $size;
674
-        }
675
-        update_option('widget_frm_show_form', $widgets);
676
-    }
677
-
678
-    /**
679
-     * Migrate post and email notification settings into actions
680
-     */
681
-    private function migrate_to_16() {
682
-        global $wpdb;
683
-
684
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
685
-
686
-        /**
687
-        * Old email settings format:
688
-        * email_to: Email or field id
689
-        * also_email_to: array of fields ids
690
-        * reply_to: Email, field id, 'custom'
691
-        * cust_reply_to: string
692
-        * reply_to_name: field id, 'custom'
693
-        * cust_reply_to_name: string
694
-        * plain_text: 0|1
695
-        * email_message: string or ''
696
-        * email_subject: string or ''
697
-        * inc_user_info: 0|1
698
-        * update_email: 0, 1, 2
699
-        *
700
-        * Old autoresponder settings format:
701
-        * auto_responder: 0|1
702
-        * ar_email_message: string or ''
703
-        * ar_email_to: field id
704
-        * ar_plain_text: 0|1
705
-        * ar_reply_to_name: string
706
-        * ar_reply_to: string
707
-        * ar_email_subject: string
708
-        * ar_update_email: 0, 1, 2
709
-        *
710
-        * New email settings:
711
-        * post_content: json settings
712
-        * post_title: form id
713
-        * post_excerpt: message
714
-        *
715
-        */
716
-
717
-        foreach ( $forms as $form ) {
674
+		}
675
+		update_option('widget_frm_show_form', $widgets);
676
+	}
677
+
678
+	/**
679
+	 * Migrate post and email notification settings into actions
680
+	 */
681
+	private function migrate_to_16() {
682
+		global $wpdb;
683
+
684
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
685
+
686
+		/**
687
+		 * Old email settings format:
688
+		 * email_to: Email or field id
689
+		 * also_email_to: array of fields ids
690
+		 * reply_to: Email, field id, 'custom'
691
+		 * cust_reply_to: string
692
+		 * reply_to_name: field id, 'custom'
693
+		 * cust_reply_to_name: string
694
+		 * plain_text: 0|1
695
+		 * email_message: string or ''
696
+		 * email_subject: string or ''
697
+		 * inc_user_info: 0|1
698
+		 * update_email: 0, 1, 2
699
+		 *
700
+		 * Old autoresponder settings format:
701
+		 * auto_responder: 0|1
702
+		 * ar_email_message: string or ''
703
+		 * ar_email_to: field id
704
+		 * ar_plain_text: 0|1
705
+		 * ar_reply_to_name: string
706
+		 * ar_reply_to: string
707
+		 * ar_email_subject: string
708
+		 * ar_update_email: 0, 1, 2
709
+		 *
710
+		 * New email settings:
711
+		 * post_content: json settings
712
+		 * post_title: form id
713
+		 * post_excerpt: message
714
+		 *
715
+		 */
716
+
717
+		foreach ( $forms as $form ) {
718 718
 			if ( $form->is_template && $form->default_template ) {
719 719
 				// don't migrate the default templates since the email will be added anyway
720 720
 				continue;
721 721
 			}
722 722
 
723
-            // Format form options
724
-            $form_options = maybe_unserialize($form->options);
723
+			// Format form options
724
+			$form_options = maybe_unserialize($form->options);
725 725
 
726
-            // Migrate settings to actions
727
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
728
-        }
729
-    }
726
+			// Migrate settings to actions
727
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
728
+		}
729
+	}
730 730
 
731
-    private function migrate_to_11() {
732
-        global $wpdb;
731
+	private function migrate_to_11() {
732
+		global $wpdb;
733 733
 
734
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
734
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options');
735 735
 
736
-        $sending = __( 'Sending', 'formidable' );
736
+		$sending = __( 'Sending', 'formidable' );
737 737
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
738
-        $old_default_html = <<<DEFAULT_HTML
738
+		$old_default_html = <<<DEFAULT_HTML
739 739
 <div class="frm_submit">
740 740
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
741 741
 <input type="submit" value="[button_label]" [button_action] />
742 742
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
743 743
 </div>
744 744
 DEFAULT_HTML;
745
-        unset($sending, $img);
745
+		unset($sending, $img);
746 746
 
747
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
748
-        $draft_link = FrmFormsHelper::get_draft_link();
747
+		$new_default_html = FrmFormsHelper::get_default_html('submit');
748
+		$draft_link = FrmFormsHelper::get_draft_link();
749 749
 		foreach ( $forms as $form ) {
750
-            $form->options = maybe_unserialize($form->options);
751
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
752
-                continue;
753
-            }
750
+			$form->options = maybe_unserialize($form->options);
751
+			if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
752
+				continue;
753
+			}
754 754
 
755
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
756
-                $form->options['submit_html'] = $new_default_html;
755
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
756
+				$form->options['submit_html'] = $new_default_html;
757 757
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
758 758
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
759 759
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
760 760
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
761
-            }
762
-            unset($form);
763
-        }
764
-        unset($forms);
765
-    }
761
+			}
762
+			unset($form);
763
+		}
764
+		unset($forms);
765
+	}
766 766
 
767
-    private function migrate_to_6() {
768
-        global $wpdb;
767
+	private function migrate_to_6() {
768
+		global $wpdb;
769 769
 
770 770
 		$no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) );
771 771
 		$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
772 772
 
773
-        $default_html = <<<DEFAULT_HTML
773
+		$default_html = <<<DEFAULT_HTML
774 774
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
775 775
     <label class="frm_pos_[label_position]">[field_name]
776 776
         <span class="frm_required">[required_label]</span>
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 </div>
781 781
 DEFAULT_HTML;
782 782
 
783
-        $old_default_html = <<<DEFAULT_HTML
783
+		$old_default_html = <<<DEFAULT_HTML
784 784
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
785 785
     <label class="frm_pos_[label_position]">[field_name]
786 786
         <span class="frm_required">[required_label]</span>
@@ -790,25 +790,25 @@  discard block
 block discarded – undo
790 790
 </div>
791 791
 DEFAULT_HTML;
792 792
 
793
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
794
-        foreach ( $fields as $field ) {
795
-            $field->field_options = maybe_unserialize($field->field_options);
793
+		$new_default_html = FrmFieldsHelper::get_default_html('text');
794
+		foreach ( $fields as $field ) {
795
+			$field->field_options = maybe_unserialize($field->field_options);
796 796
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
797
-                $field->field_options['custom_html'] = $new_default_html;
797
+				$field->field_options['custom_html'] = $new_default_html;
798 798
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
799
-            }
800
-            unset($field);
801
-        }
802
-        unset($default_html, $old_default_html, $fields);
803
-    }
804
-
805
-    private function migrate_to_4() {
806
-        global $wpdb;
799
+			}
800
+			unset($field);
801
+		}
802
+		unset($default_html, $old_default_html, $fields);
803
+	}
804
+
805
+	private function migrate_to_4() {
806
+		global $wpdb;
807 807
 		$user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) );
808
-        foreach ( $user_ids as $user_id ) {
808
+		foreach ( $user_ids as $user_id ) {
809 809
 			$wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) );
810
-        }
811
-    }
810
+		}
811
+	}
812 812
 
813 813
 	public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) {
814 814
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' );
Please login to merge, or discard this patch.