Completed
Push — master ( dd13f0...90a113 )
by Jamie
03:12
created
classes/helpers/FrmAppHelper.php 1 patch
Spacing   +203 added lines, -203 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 ) {
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public static function get_settings() {
81 81
         global $frm_settings;
82
-        if ( empty($frm_settings) ) {
82
+        if ( empty( $frm_settings ) ) {
83 83
             $frm_settings = new FrmSettings();
84 84
         }
85 85
         return $frm_settings;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     }
101 101
 
102 102
     public static function pro_is_installed() {
103
-        return apply_filters('frm_pro_installed', false);
103
+        return apply_filters( 'frm_pro_installed', false );
104 104
     }
105 105
 
106 106
     /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      * @return boolean
145 145
      */
146 146
     public static function doing_ajax() {
147
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
147
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
148 148
     }
149 149
 
150 150
 	/**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * @return boolean
165 165
      */
166 166
     public static function is_admin() {
167
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
167
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
168 168
     }
169 169
 
170 170
     /**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @return string
192 192
      */
193 193
 	public static function get_server_value( $value ) {
194
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
194
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
195 195
     }
196 196
 
197 197
     /**
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
207 207
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
208 208
         ) as $key ) {
209
-            if ( ! isset( $_SERVER[ $key ] ) ) {
209
+            if ( ! isset( $_SERVER[$key] ) ) {
210 210
                 continue;
211 211
             }
212 212
 
213
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
214
-                $ip = trim($ip); // just to be safe
213
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
214
+                $ip = trim( $ip ); // just to be safe
215 215
 
216
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
216
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
217 217
                     return $ip;
218 218
                 }
219 219
             }
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
     }
224 224
 
225 225
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
226
-        if ( strpos($param, '[') ) {
227
-            $params = explode('[', $param);
226
+        if ( strpos( $param, '[' ) ) {
227
+            $params = explode( '[', $param );
228 228
             $param = $params[0];
229 229
         }
230 230
 
231 231
 		if ( $src == 'get' ) {
232
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
233
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
234
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
232
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
233
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
234
+                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) );
235 235
             }
236 236
 			self::sanitize_value( $sanitize, $value );
237 237
 		} else {
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
 
241 241
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
242 242
             foreach ( $params as $k => $p ) {
243
-                if ( ! $k || ! is_array($value) ) {
243
+                if ( ! $k || ! is_array( $value ) ) {
244 244
                     continue;
245 245
                 }
246 246
 
247
-                $p = trim($p, ']');
248
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
247
+                $p = trim( $p, ']' );
248
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
249 249
             }
250 250
         }
251 251
 
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
 
285 285
 		$value = $args['default'];
286 286
 		if ( $args['type'] == 'get' ) {
287
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
288
-				$value = $_GET[ $args['param'] ];
287
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
288
+				$value = $_GET[$args['param']];
289 289
 			}
290 290
 		} else if ( $args['type'] == 'post' ) {
291
-			if ( isset( $_POST[ $args['param'] ] ) ) {
292
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
291
+			if ( isset( $_POST[$args['param']] ) ) {
292
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
293 293
 			}
294 294
 		} else {
295
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
296
-				$value = $_REQUEST[ $args['param'] ];
295
+			if ( isset( $_REQUEST[$args['param']] ) ) {
296
+				$value = $_REQUEST[$args['param']];
297 297
 			}
298 298
 		}
299 299
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			if ( is_array( $value ) ) {
322 322
 				$temp_values = $value;
323 323
 				foreach ( $temp_values as $k => $v ) {
324
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
324
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
325 325
 				}
326 326
 			} else {
327 327
 				$value = call_user_func( $sanitize, $value );
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
     public static function sanitize_request( $sanitize_method, &$values ) {
333 333
         $temp_values = $values;
334 334
         foreach ( $temp_values as $k => $val ) {
335
-            if ( isset( $sanitize_method[ $k ] ) ) {
336
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
335
+            if ( isset( $sanitize_method[$k] ) ) {
336
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
337 337
             }
338 338
         }
339 339
     }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	public static function sanitize_array( &$values ) {
342 342
 		$temp_values = $values;
343 343
 		foreach ( $temp_values as $k => $val ) {
344
-			$values[ $k ] = wp_kses_post( $val );
344
+			$values[$k] = wp_kses_post( $val );
345 345
 		}
346 346
 	}
347 347
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 
365 365
 		$allowed_html = array();
366 366
 		foreach ( $allowed as $a ) {
367
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
367
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
368 368
 		}
369 369
 
370 370
 		return wp_kses( $value, $allowed_html );
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      * @since 2.0
376 376
      */
377 377
     public static function remove_get_action() {
378
-        if ( ! isset($_GET) ) {
378
+        if ( ! isset( $_GET ) ) {
379 379
             return;
380 380
         }
381 381
 
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
         }
398 398
 
399 399
         global $wp_query;
400
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
401
-            $value = $wp_query->query_vars[ $param ];
400
+        if ( isset( $wp_query->query_vars[$param] ) ) {
401
+            $value = $wp_query->query_vars[$param];
402 402
         }
403 403
 
404 404
         return $value;
@@ -427,19 +427,19 @@  discard block
 block discarded – undo
427 427
      * @return mixed $results The cache or query results
428 428
      */
429 429
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
430
-        $results = wp_cache_get($cache_key, $group);
431
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
430
+        $results = wp_cache_get( $cache_key, $group );
431
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
432 432
             return $results;
433 433
         }
434 434
 
435 435
         if ( 'get_posts' == $type ) {
436
-            $results = get_posts($query);
436
+            $results = get_posts( $query );
437 437
 		} else if ( 'get_associative_results' == $type ) {
438 438
 			global $wpdb;
439 439
 			$results = $wpdb->get_results( $query, OBJECT_K );
440 440
         } else {
441 441
             global $wpdb;
442
-            $results = $wpdb->{$type}($query);
442
+            $results = $wpdb->{$type}( $query );
443 443
         }
444 444
 
445 445
 		self::set_cache( $cache_key, $results, $group, $time );
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 	 */
461 461
 	public static function add_key_to_group_cache( $key, $group ) {
462 462
 		$cached = self::get_group_cached_keys( $group );
463
-		$cached[ $key ] = $key;
463
+		$cached[$key] = $key;
464 464
 		wp_cache_set( 'cached_keys', $cached, $group, 300 );
465 465
 	}
466 466
 
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
         }
488 488
 
489 489
         // then check the transient
490
-        $results = get_transient($cache_key);
490
+        $results = get_transient( $cache_key );
491 491
         if ( $results ) {
492
-            wp_cache_set($cache_key, $results);
492
+            wp_cache_set( $cache_key, $results );
493 493
         }
494 494
 
495 495
         return $results;
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
      * @param string $cache_key
501 501
      */
502 502
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
503
-		delete_transient($cache_key);
503
+		delete_transient( $cache_key );
504 504
 		wp_cache_delete( $cache_key, $group );
505 505
 	}
506 506
 
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
     }
545 545
 
546 546
     public static function get_pages() {
547
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
547
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
548 548
     }
549 549
 
550 550
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
551 551
         $pages = self::get_pages();
552 552
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
553 553
     ?>
554
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
554
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
555 555
             <option value=""> </option>
556 556
             <?php foreach ( $pages as $page ) { ?>
557
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
557
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
558 558
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
559 559
 				</option>
560 560
             <?php } ?>
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
     }
564 564
 
565 565
 	public static function post_edit_link( $post_id ) {
566
-        $post = get_post($post_id);
566
+        $post = get_post( $post_id );
567 567
         if ( $post ) {
568 568
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
569 569
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -573,17 +573,17 @@  discard block
 block discarded – undo
573 573
 
574 574
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
575 575
     ?>
576
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
576
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
577 577
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
578 578
             ?> class="frm_multiselect">
579
-            <?php self::roles_options($capability); ?>
579
+            <?php self::roles_options( $capability ); ?>
580 580
         </select>
581 581
     <?php
582 582
     }
583 583
 
584 584
 	public static function roles_options( $capability ) {
585 585
         global $frm_vars;
586
-        if ( isset($frm_vars['editable_roles']) ) {
586
+        if ( isset( $frm_vars['editable_roles'] ) ) {
587 587
             $editable_roles = $frm_vars['editable_roles'];
588 588
         } else {
589 589
             $editable_roles = get_editable_roles();
@@ -591,10 +591,10 @@  discard block
 block discarded – undo
591 591
         }
592 592
 
593 593
         foreach ( $editable_roles as $role => $details ) {
594
-            $name = translate_user_role($details['name'] ); ?>
595
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
594
+            $name = translate_user_role( $details['name'] ); ?>
595
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
596 596
 <?php
597
-            unset($role, $details);
597
+            unset( $role, $details );
598 598
         }
599 599
     }
600 600
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
     public static function maybe_add_permissions() {
651 651
 		self::force_capability( 'frm_view_entries' );
652 652
 
653
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
653
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
654 654
             return;
655 655
         }
656 656
 
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
         $frm_roles = self::frm_capabilities();
660 660
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
661 661
 			$user->add_cap( $frm_role );
662
-            unset($frm_role, $frm_role_description);
662
+            unset( $frm_role, $frm_role_description );
663 663
         }
664 664
     }
665 665
 
@@ -684,12 +684,12 @@  discard block
 block discarded – undo
684 684
      * @param string $permission
685 685
      */
686 686
 	public static function permission_check( $permission, $show_message = 'show' ) {
687
-        $permission_error = self::permission_nonce_error($permission);
687
+        $permission_error = self::permission_nonce_error( $permission );
688 688
         if ( $permission_error !== false ) {
689 689
             if ( 'hide' == $show_message ) {
690 690
                 $permission_error = '';
691 691
             }
692
-            wp_die($permission_error);
692
+            wp_die( $permission_error );
693 693
         }
694 694
     }
695 695
 
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
 		}
707 707
 
708 708
 		$error = false;
709
-        if ( empty($nonce_name) ) {
709
+        if ( empty( $nonce_name ) ) {
710 710
             return $error;
711 711
         }
712 712
 
713
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
713
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
714 714
             $frm_settings = self::get_settings();
715 715
             $error = $frm_settings->admin_permission;
716 716
         }
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 			} else {
791 791
 				foreach ( $value as $k => $v ) {
792 792
 					if ( ! is_array( $v ) ) {
793
-						$value[ $k ] = call_user_func( $original_function, $v );
793
+						$value[$k] = call_user_func( $original_function, $v );
794 794
 					}
795 795
 				}
796 796
 			}
@@ -811,11 +811,11 @@  discard block
 block discarded – undo
811 811
 	public static function array_flatten( $array, $keys = 'keep' ) {
812 812
         $return = array();
813 813
         foreach ( $array as $key => $value ) {
814
-            if ( is_array($value) ) {
814
+            if ( is_array( $value ) ) {
815 815
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
816 816
             } else {
817 817
 				if ( $keys == 'keep' ) {
818
-					$return[ $key ] = $value;
818
+					$return[$key] = $value;
819 819
 				} else {
820 820
 					$return[] = $value;
821 821
 				}
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
      * @since 2.0
839 839
      */
840 840
 	public static function use_wpautop( $content ) {
841
-        if ( apply_filters('frm_use_wpautop', true) ) {
842
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
841
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
842
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
843 843
         }
844 844
         return $content;
845 845
     }
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
      */
859 859
     public static function jquery_ui_base_url() {
860 860
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
861
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
861
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
862 862
         return $url;
863 863
     }
864 864
 
@@ -872,11 +872,11 @@  discard block
 block discarded – undo
872 872
 		}
873 873
 
874 874
 		$ver = $default;
875
-		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
875
+		if ( ! isset( $wp_scripts->registered[$handle] ) ) {
876 876
 			return $ver;
877 877
 		}
878 878
 
879
-		$query = $wp_scripts->registered[ $handle ];
879
+		$query = $wp_scripts->registered[$handle];
880 880
 		if ( is_object( $query ) && ! empty( $query->ver ) ) {
881 881
 			$ver = $query->ver;
882 882
 		}
@@ -889,36 +889,36 @@  discard block
 block discarded – undo
889 889
     }
890 890
 
891 891
 	public static function get_user_id_param( $user_id ) {
892
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
892
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
893 893
             return $user_id;
894 894
         }
895 895
 
896 896
 		if ( $user_id == 'current' ) {
897 897
 			$user_id = get_current_user_id();
898 898
 		} else {
899
-            if ( is_email($user_id) ) {
900
-                $user = get_user_by('email', $user_id);
899
+            if ( is_email( $user_id ) ) {
900
+                $user = get_user_by( 'email', $user_id );
901 901
             } else {
902
-                $user = get_user_by('login', $user_id);
902
+                $user = get_user_by( 'login', $user_id );
903 903
             }
904 904
 
905 905
             if ( $user ) {
906 906
                 $user_id = $user->ID;
907 907
             }
908
-            unset($user);
908
+            unset( $user );
909 909
         }
910 910
 
911 911
         return $user_id;
912 912
     }
913 913
 
914 914
 	public static function get_file_contents( $filename, $atts = array() ) {
915
-        if ( ! is_file($filename) ) {
915
+        if ( ! is_file( $filename ) ) {
916 916
             return false;
917 917
         }
918 918
 
919
-        extract($atts);
919
+        extract( $atts );
920 920
         ob_start();
921
-        include($filename);
921
+        include( $filename );
922 922
         $contents = ob_get_contents();
923 923
         ob_end_clean();
924 924
         return $contents;
@@ -934,27 +934,27 @@  discard block
 block discarded – undo
934 934
         $key = '';
935 935
 
936 936
         if ( ! empty( $name ) ) {
937
-            $key = sanitize_key($name);
937
+            $key = sanitize_key( $name );
938 938
         }
939 939
 
940 940
 		if ( empty( $key ) ) {
941
-            $max_slug_value = pow(36, $num_chars);
941
+            $max_slug_value = pow( 36, $num_chars );
942 942
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
943
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
943
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
944 944
         }
945 945
 
946
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
946
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
947 947
 			$key = $key . 'a';
948 948
         }
949 949
 
950 950
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
951 951
 
952
-        if ( $key_check || is_numeric($key_check) ) {
952
+        if ( $key_check || is_numeric( $key_check ) ) {
953 953
             $suffix = 2;
954 954
 			do {
955 955
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
956 956
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
957
-				$suffix++;
957
+				$suffix ++;
958 958
 			} while ( $key_check || is_numeric( $key_check ) );
959 959
 			$key = $alt_post_name;
960 960
         }
@@ -971,32 +971,32 @@  discard block
 block discarded – undo
971 971
             return false;
972 972
         }
973 973
 
974
-        if ( empty($post_values) ) {
975
-            $post_values = stripslashes_deep($_POST);
974
+        if ( empty( $post_values ) ) {
975
+            $post_values = stripslashes_deep( $_POST );
976 976
         }
977 977
 
978 978
 		$values = array( 'id' => $record->id, 'fields' => array() );
979 979
 
980 980
 		foreach ( array( 'name', 'description' ) as $var ) {
981
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
982
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
983
-            unset($var, $default_val);
981
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
982
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
983
+            unset( $var, $default_val );
984 984
         }
985 985
 
986
-        $values['description'] = self::use_wpautop($values['description']);
986
+        $values['description'] = self::use_wpautop( $values['description'] );
987 987
         $frm_settings = self::get_settings();
988
-        $is_form_builder = self::is_admin_page('formidable' );
988
+        $is_form_builder = self::is_admin_page( 'formidable' );
989 989
 
990 990
         foreach ( (array) $fields as $field ) {
991 991
             // Make sure to filter default values (for placeholder text), but not on the form builder page
992 992
             if ( ! $is_form_builder ) {
993
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
993
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
994 994
             }
995 995
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
996
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
996
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
997 997
         }
998 998
 
999
-        self::fill_form_opts($record, $table, $post_values, $values);
999
+        self::fill_form_opts( $record, $table, $post_values, $values );
1000 1000
 
1001 1001
         if ( $table == 'entries' ) {
1002 1002
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
         if ( $args['default'] ) {
1014 1014
             $meta_value = $field->default_value;
1015 1015
         } else {
1016
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1017
-                if ( ! isset($field->field_options['custom_field']) ) {
1016
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1017
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1018 1018
                     $field->field_options['custom_field'] = '';
1019 1019
                 }
1020 1020
 				$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 ) );
@@ -1023,8 +1023,8 @@  discard block
 block discarded – undo
1023 1023
             }
1024 1024
         }
1025 1025
 
1026
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1027
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1026
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1027
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1028 1028
 
1029 1029
         $field_array = array(
1030 1030
             'id'            => $field->id,
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
             'default_value' => $field->default_value,
1033 1033
             'name'          => $field->name,
1034 1034
             'description'   => $field->description,
1035
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1035
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1036 1036
             'options'       => $field->options,
1037 1037
             'required'      => $field->required,
1038 1038
             'field_key'     => $field->field_key,
@@ -1042,40 +1042,40 @@  discard block
 block discarded – undo
1042 1042
         );
1043 1043
 
1044 1044
         $args['field_type'] = $field_type;
1045
-        self::fill_field_opts($field, $field_array, $args);
1045
+        self::fill_field_opts( $field, $field_array, $args );
1046 1046
 		// Track the original field's type
1047 1047
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1048 1048
 
1049 1049
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1050 1050
 
1051
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1051
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1052 1052
             $field_array['unique_msg'] = '';
1053 1053
         }
1054 1054
 
1055 1055
         $field_array = array_merge( $field->field_options, $field_array );
1056 1056
 
1057
-        $values['fields'][ $field->id ] = $field_array;
1057
+        $values['fields'][$field->id] = $field_array;
1058 1058
     }
1059 1059
 
1060 1060
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1061 1061
         $post_values = $args['post_values'];
1062
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1062
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1063 1063
 
1064 1064
         foreach ( $opt_defaults as $opt => $default_opt ) {
1065
-			$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 );
1066
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1067
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1068
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1065
+			$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 );
1066
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1067
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1068
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1069 1069
                 if ( $args['field_type'] == 'captcha' ) {
1070
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1070
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1071 1071
                 } else {
1072
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1072
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1073 1073
                 }
1074 1074
             }
1075 1075
         }
1076 1076
 
1077 1077
         if ( $field_array['custom_html'] == '' ) {
1078
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1078
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1079 1079
         }
1080 1080
     }
1081 1081
 
@@ -1094,18 +1094,18 @@  discard block
 block discarded – undo
1094 1094
             return;
1095 1095
         }
1096 1096
 
1097
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1097
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1098 1098
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1099 1099
 
1100
-        if ( ! is_array($form->options) ) {
1100
+        if ( ! is_array( $form->options ) ) {
1101 1101
             return;
1102 1102
         }
1103 1103
 
1104 1104
         foreach ( $form->options as $opt => $value ) {
1105
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1105
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1106 1106
         }
1107 1107
 
1108
-        self::fill_form_defaults($post_values, $values);
1108
+        self::fill_form_defaults( $post_values, $values );
1109 1109
     }
1110 1110
 
1111 1111
     /**
@@ -1115,11 +1115,11 @@  discard block
 block discarded – undo
1115 1115
         $form_defaults = FrmFormsHelper::get_default_opts();
1116 1116
 
1117 1117
         foreach ( $form_defaults as $opt => $default ) {
1118
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1119
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1118
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1119
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1120 1120
             }
1121 1121
 
1122
-            unset($opt, $defaut);
1122
+            unset( $opt, $defaut );
1123 1123
         }
1124 1124
 
1125 1125
 		if ( ! isset( $values['custom_style'] ) ) {
@@ -1127,10 +1127,10 @@  discard block
 block discarded – undo
1127 1127
 		}
1128 1128
 
1129 1129
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1130
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1131
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1130
+			if ( ! isset( $values[$h . '_html'] ) ) {
1131
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1132 1132
             }
1133
-            unset($h);
1133
+            unset( $h );
1134 1134
         }
1135 1135
     }
1136 1136
 
@@ -1161,9 +1161,9 @@  discard block
 block discarded – undo
1161 1161
         }
1162 1162
     ?>
1163 1163
 <li>
1164
-    <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>
1165
-    <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>
1166
-    <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>
1164
+    <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>
1165
+    <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>
1166
+    <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>
1167 1167
 </li>
1168 1168
     <?php
1169 1169
     }
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
             return '';
1182 1182
         } else if ( $length <= 10 ) {
1183 1183
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1184
-            return $sub . (($length < $original_len) ? $continue : '');
1184
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1185 1185
         }
1186 1186
 
1187 1187
         $sub = '';
@@ -1190,23 +1190,23 @@  discard block
 block discarded – undo
1190 1190
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1191 1191
 
1192 1192
 		foreach ( $words as $word ) {
1193
-            $part = (($sub != '') ? ' ' : '') . $word;
1193
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1194 1194
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1195
-            if ( $total_len > $length && str_word_count($sub) ) {
1195
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1196 1196
                 break;
1197 1197
             }
1198 1198
 
1199 1199
             $sub .= $part;
1200 1200
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1201 1201
 
1202
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1202
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1203 1203
                 break;
1204 1204
             }
1205 1205
 
1206
-            unset($total_len, $word);
1206
+            unset( $total_len, $word );
1207 1207
         }
1208 1208
 
1209
-        return $sub . (($len < $original_len) ? $continue : '');
1209
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1210 1210
     }
1211 1211
 
1212 1212
 	public static function mb_function( $function_names, $args ) {
@@ -1219,17 +1219,17 @@  discard block
 block discarded – undo
1219 1219
 	}
1220 1220
 
1221 1221
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1222
-        if ( empty($date) ) {
1222
+        if ( empty( $date ) ) {
1223 1223
             return $date;
1224 1224
         }
1225 1225
 
1226
-        if ( empty($date_format) ) {
1227
-            $date_format = get_option('date_format');
1226
+        if ( empty( $date_format ) ) {
1227
+            $date_format = get_option( 'date_format' );
1228 1228
         }
1229 1229
 
1230
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1230
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1231 1231
             $frmpro_settings = new FrmProSettings();
1232
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1232
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1233 1233
         }
1234 1234
 
1235 1235
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 
1245 1245
 	private static function add_time_to_date( $time_format, $date ) {
1246 1246
 		if ( empty( $time_format ) ) {
1247
-			$time_format = get_option('time_format');
1247
+			$time_format = get_option( 'time_format' );
1248 1248
 		}
1249 1249
 
1250 1250
 		$trimmed_format = trim( $time_format );
@@ -1290,10 +1290,10 @@  discard block
 block discarded – undo
1290 1290
 		$time_strings = self::get_time_strings();
1291 1291
 
1292 1292
 		foreach ( $time_strings as $k => $v ) {
1293
-			if ( $diff[ $k ] ) {
1294
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1293
+			if ( $diff[$k] ) {
1294
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1295 1295
 			} else {
1296
-				unset( $time_strings[ $k ] );
1296
+				unset( $time_strings[$k] );
1297 1297
 			}
1298 1298
 		}
1299 1299
 
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
      */
1333 1333
 	public static function esc_like( $term ) {
1334 1334
         global $wpdb;
1335
-        if ( method_exists($wpdb, 'esc_like') ) {
1335
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1336 1336
 			// WP 4.0
1337 1337
             $term = $wpdb->esc_like( $term );
1338 1338
         } else {
@@ -1346,17 +1346,17 @@  discard block
 block discarded – undo
1346 1346
      * @param string $order_query
1347 1347
      */
1348 1348
 	public static function esc_order( $order_query ) {
1349
-        if ( empty($order_query) ) {
1349
+        if ( empty( $order_query ) ) {
1350 1350
             return '';
1351 1351
         }
1352 1352
 
1353 1353
         // remove ORDER BY before santizing
1354
-        $order_query = strtolower($order_query);
1355
-        if ( strpos($order_query, 'order by') !== false ) {
1356
-            $order_query = str_replace('order by', '', $order_query);
1354
+        $order_query = strtolower( $order_query );
1355
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1356
+            $order_query = str_replace( 'order by', '', $order_query );
1357 1357
         }
1358 1358
 
1359
-        $order_query = explode(' ', trim($order_query));
1359
+        $order_query = explode( ' ', trim( $order_query ) );
1360 1360
 
1361 1361
         $order_fields = array(
1362 1362
             'id', 'form_key', 'name', 'description',
@@ -1364,13 +1364,13 @@  discard block
 block discarded – undo
1364 1364
             'default_template', 'status', 'created_at',
1365 1365
         );
1366 1366
 
1367
-        $order = trim(trim(reset($order_query), ','));
1368
-        if ( ! in_array($order, $order_fields) ) {
1367
+        $order = trim( trim( reset( $order_query ), ',' ) );
1368
+        if ( ! in_array( $order, $order_fields ) ) {
1369 1369
             return '';
1370 1370
         }
1371 1371
 
1372 1372
         $order_by = '';
1373
-        if ( count($order_query) > 1 ) {
1373
+        if ( count( $order_query ) > 1 ) {
1374 1374
 			$order_by = end( $order_query );
1375 1375
 			self::esc_order_by( $order_by );
1376 1376
         }
@@ -1392,23 +1392,23 @@  discard block
 block discarded – undo
1392 1392
      * @param string $limit
1393 1393
      */
1394 1394
 	public static function esc_limit( $limit ) {
1395
-        if ( empty($limit) ) {
1395
+        if ( empty( $limit ) ) {
1396 1396
             return '';
1397 1397
         }
1398 1398
 
1399
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1400
-        if ( is_numeric($limit) ) {
1399
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1400
+        if ( is_numeric( $limit ) ) {
1401 1401
 			return ' LIMIT ' . $limit;
1402 1402
         }
1403 1403
 
1404
-        $limit = explode(',', trim($limit));
1404
+        $limit = explode( ',', trim( $limit ) );
1405 1405
         foreach ( $limit as $k => $l ) {
1406 1406
             if ( is_numeric( $l ) ) {
1407
-                $limit[ $k ] = $l;
1407
+                $limit[$k] = $l;
1408 1408
             }
1409 1409
         }
1410 1410
 
1411
-        $limit = implode(',', $limit);
1411
+        $limit = implode( ',', $limit );
1412 1412
 		return ' LIMIT ' . $limit;
1413 1413
     }
1414 1414
 
@@ -1417,12 +1417,12 @@  discard block
 block discarded – undo
1417 1417
      * @since 2.0
1418 1418
      */
1419 1419
     public static function prepare_array_values( $array, $type = '%s' ) {
1420
-        $placeholders = array_fill(0, count($array), $type);
1421
-        return implode(', ', $placeholders);
1420
+        $placeholders = array_fill( 0, count( $array ), $type );
1421
+        return implode( ', ', $placeholders );
1422 1422
     }
1423 1423
 
1424 1424
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1425
-        if ( empty($where) ) {
1425
+        if ( empty( $where ) ) {
1426 1426
             return '';
1427 1427
         }
1428 1428
 
@@ -1463,19 +1463,19 @@  discard block
 block discarded – undo
1463 1463
 	public static function json_to_array( $json_vars ) {
1464 1464
         $vars = array();
1465 1465
         foreach ( $json_vars as $jv ) {
1466
-            $jv_name = explode('[', $jv['name']);
1467
-            $last = count($jv_name) - 1;
1466
+            $jv_name = explode( '[', $jv['name'] );
1467
+            $last = count( $jv_name ) - 1;
1468 1468
             foreach ( $jv_name as $p => $n ) {
1469
-                $name = trim($n, ']');
1470
-                if ( ! isset($l1) ) {
1469
+                $name = trim( $n, ']' );
1470
+                if ( ! isset( $l1 ) ) {
1471 1471
                     $l1 = $name;
1472 1472
                 }
1473 1473
 
1474
-                if ( ! isset($l2) ) {
1474
+                if ( ! isset( $l2 ) ) {
1475 1475
                     $l2 = $name;
1476 1476
                 }
1477 1477
 
1478
-                if ( ! isset($l3) ) {
1478
+                if ( ! isset( $l3 ) ) {
1479 1479
                     $l3 = $name;
1480 1480
                 }
1481 1481
 
@@ -1489,24 +1489,24 @@  discard block
 block discarded – undo
1489 1489
 
1490 1490
                     case 1:
1491 1491
                         $l2 = $name;
1492
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1492
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1493 1493
                     break;
1494 1494
 
1495 1495
                     case 2:
1496 1496
                         $l3 = $name;
1497
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1497
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1498 1498
                     break;
1499 1499
 
1500 1500
                     case 3:
1501 1501
                         $l4 = $name;
1502
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1502
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1503 1503
                     break;
1504 1504
                 }
1505 1505
 
1506
-                unset($this_val, $n);
1506
+                unset( $this_val, $n );
1507 1507
             }
1508 1508
 
1509
-            unset($last, $jv);
1509
+            unset( $last, $jv );
1510 1510
         }
1511 1511
 
1512 1512
         return $vars;
@@ -1519,8 +1519,8 @@  discard block
 block discarded – undo
1519 1519
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1520 1520
         if ( $name == '' ) {
1521 1521
             $vars[] = $val;
1522
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1523
-            $vars[ $l1 ] = $val;
1522
+        } else if ( ! isset( $vars[$l1] ) ) {
1523
+            $vars[$l1] = $val;
1524 1524
         }
1525 1525
     }
1526 1526
 
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
             '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() ) ),
1536 1536
         );
1537 1537
 
1538
-        if ( ! isset( $tooltips[ $name ] ) ) {
1538
+        if ( ! isset( $tooltips[$name] ) ) {
1539 1539
             return;
1540 1540
         }
1541 1541
 
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
             echo ' class="frm_help"';
1546 1546
         }
1547 1547
 
1548
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1548
+		echo ' title="' . esc_attr( $tooltips[$name] );
1549 1549
 
1550 1550
         if ( 'open' != $class ) {
1551 1551
             echo '"';
@@ -1597,13 +1597,13 @@  discard block
 block discarded – undo
1597 1597
     }
1598 1598
 
1599 1599
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1600
-		if ( ! isset( $post_content[ $key ] ) ) {
1600
+		if ( ! isset( $post_content[$key] ) ) {
1601 1601
 			return;
1602 1602
 		}
1603 1603
 
1604 1604
 		if ( is_array( $val ) ) {
1605 1605
 			foreach ( $val as $k1 => $v1 ) {
1606
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1606
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1607 1607
 				unset( $k1, $v1 );
1608 1608
 			}
1609 1609
 		} else {
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
 			$val = stripslashes( $val );
1612 1612
 
1613 1613
 			// Add backslashes before double quotes and forward slashes only
1614
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1614
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1615 1615
 		}
1616 1616
 	}
1617 1617
 
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1629 1629
 
1630 1630
 		if ( empty( $settings['ID'] ) ) {
1631
-			unset( $settings['ID']);
1631
+			unset( $settings['ID'] );
1632 1632
 		}
1633 1633
 
1634 1634
 		// delete all caches for this group
@@ -1662,17 +1662,17 @@  discard block
 block discarded – undo
1662 1662
 	}
1663 1663
 
1664 1664
 	public static function maybe_json_decode( $string ) {
1665
-        if ( is_array($string) ) {
1665
+        if ( is_array( $string ) ) {
1666 1666
             return $string;
1667 1667
         }
1668 1668
 
1669
-        $new_string = json_decode($string, true);
1670
-        if ( function_exists('json_last_error') ) {
1669
+        $new_string = json_decode( $string, true );
1670
+        if ( function_exists( 'json_last_error' ) ) {
1671 1671
 			// php 5.3+
1672 1672
             if ( json_last_error() == JSON_ERROR_NONE ) {
1673 1673
                 $string = $new_string;
1674 1674
             }
1675
-        } else if ( isset($new_string) ) {
1675
+        } else if ( isset( $new_string ) ) {
1676 1676
 			// php < 5.3 fallback
1677 1677
             $string = $new_string;
1678 1678
         }
@@ -1688,11 +1688,11 @@  discard block
 block discarded – undo
1688 1688
 	public static function maybe_highlight_menu( $post_type ) {
1689 1689
         global $post;
1690 1690
 
1691
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1691
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1692 1692
             return;
1693 1693
         }
1694 1694
 
1695
-        if ( is_object($post) && $post->post_type != $post_type ) {
1695
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1696 1696
             return;
1697 1697
         }
1698 1698
 
@@ -1793,11 +1793,11 @@  discard block
 block discarded – undo
1793 1793
         $frm_version = self::plugin_version();
1794 1794
 
1795 1795
         // check if Formidable meets minimum requirements
1796
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1796
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1797 1797
             return;
1798 1798
         }
1799 1799
 
1800
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1800
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1801 1801
 		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">' .
1802 1802
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1803 1803
         '</div></td></tr>';
@@ -1805,38 +1805,38 @@  discard block
 block discarded – undo
1805 1805
 
1806 1806
     public static function locales( $type = 'date' ) {
1807 1807
         $locales = array(
1808
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1809
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1810
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1808
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1809
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1810
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1811 1811
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1812
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1813
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1812
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1813
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1814 1814
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1815
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1816
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1815
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1816
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1817 1817
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1818
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1818
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1819 1819
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1820
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1820
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1821 1821
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1822
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1822
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1823 1823
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1824
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1825
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1826
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1827
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1828
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1824
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1825
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1826
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1827
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1828
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1829 1829
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1830
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1830
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1831 1831
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1832 1832
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1833
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1833
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1834 1834
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1835
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1835
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1836 1836
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1837
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1838
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1839
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1837
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1838
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1839
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1840 1840
         );
1841 1841
 
1842 1842
         if ( $type == 'captcha' ) {
@@ -1855,8 +1855,8 @@  discard block
 block discarded – undo
1855 1855
             );
1856 1856
         }
1857 1857
 
1858
-        $locales = array_diff_key($locales, array_flip($unset));
1859
-        $locales = apply_filters('frm_locales', $locales);
1858
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1859
+        $locales = apply_filters( 'frm_locales', $locales );
1860 1860
 
1861 1861
         return $locales;
1862 1862
     }
Please login to merge, or discard this patch.