Completed
Push — master ( e17ff4...0b03ab )
by Stephanie
02:50
created
classes/helpers/FrmAppHelper.php 1 patch
Spacing   +149 added lines, -149 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 ) {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public static function get_settings() {
82 82
         global $frm_settings;
83
-        if ( empty($frm_settings) ) {
83
+        if ( empty( $frm_settings ) ) {
84 84
             $frm_settings = new FrmSettings();
85 85
         }
86 86
         return $frm_settings;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     }
110 110
 
111 111
     public static function pro_is_installed() {
112
-        return apply_filters('frm_pro_installed', false);
112
+        return apply_filters( 'frm_pro_installed', false );
113 113
     }
114 114
 
115 115
     /**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		if ( function_exists( 'wp_doing_ajax' ) ) {
165 165
 			$doing_ajax = wp_doing_ajax();
166 166
 		} else {
167
-			$doing_ajax = defined('DOING_AJAX') && DOING_AJAX;
167
+			$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
168 168
 		}
169 169
 		return $doing_ajax;
170 170
 	}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @return string
214 214
      */
215 215
 	public static function get_server_value( $value ) {
216
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
216
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
217 217
     }
218 218
 
219 219
     /**
@@ -225,14 +225,14 @@  discard block
 block discarded – undo
225 225
     public static function get_ip_address() {
226 226
 		$ip = '';
227 227
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
228
-            if ( ! isset( $_SERVER[ $key ] ) ) {
228
+            if ( ! isset( $_SERVER[$key] ) ) {
229 229
                 continue;
230 230
             }
231 231
 
232
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
233
-                $ip = trim($ip); // just to be safe
232
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
233
+                $ip = trim( $ip ); // just to be safe
234 234
 
235
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
235
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
236 236
                     return sanitize_text_field( $ip );
237 237
                 }
238 238
             }
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
     }
243 243
 
244 244
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
245
-        if ( strpos($param, '[') ) {
246
-            $params = explode('[', $param);
245
+        if ( strpos( $param, '[' ) ) {
246
+            $params = explode( '[', $param );
247 247
             $param = $params[0];
248 248
         }
249 249
 
250 250
 		if ( $src == 'get' ) {
251
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
252
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
253
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
251
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
252
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
253
+                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) );
254 254
             }
255 255
 			self::sanitize_value( $sanitize, $value );
256 256
 		} else {
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 
265 265
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
266 266
             foreach ( $params as $k => $p ) {
267
-                if ( ! $k || ! is_array($value) ) {
267
+                if ( ! $k || ! is_array( $value ) ) {
268 268
                     continue;
269 269
                 }
270 270
 
271
-                $p = trim($p, ']');
272
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
271
+                $p = trim( $p, ']' );
272
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
273 273
             }
274 274
         }
275 275
 
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
 
321 321
 		$value = $args['default'];
322 322
 		if ( $args['type'] == 'get' ) {
323
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
324
-				$value = $_GET[ $args['param'] ];
323
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
324
+				$value = $_GET[$args['param']];
325 325
 			}
326 326
 		} else if ( $args['type'] == 'post' ) {
327
-			if ( isset( $_POST[ $args['param'] ] ) ) {
328
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
327
+			if ( isset( $_POST[$args['param']] ) ) {
328
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
329 329
 			}
330 330
 		} else {
331
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
332
-				$value = $_REQUEST[ $args['param'] ];
331
+			if ( isset( $_REQUEST[$args['param']] ) ) {
332
+				$value = $_REQUEST[$args['param']];
333 333
 			}
334 334
 		}
335 335
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 			if ( is_array( $value ) ) {
358 358
 				$temp_values = $value;
359 359
 				foreach ( $temp_values as $k => $v ) {
360
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
360
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
361 361
 				}
362 362
 			} else {
363 363
 				$value = call_user_func( $sanitize, $value );
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
     public static function sanitize_request( $sanitize_method, &$values ) {
369 369
         $temp_values = $values;
370 370
         foreach ( $temp_values as $k => $val ) {
371
-            if ( isset( $sanitize_method[ $k ] ) ) {
372
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
371
+            if ( isset( $sanitize_method[$k] ) ) {
372
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
373 373
             }
374 374
         }
375 375
     }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	public static function sanitize_array( &$values ) {
378 378
 		$temp_values = $values;
379 379
 		foreach ( $temp_values as $k => $val ) {
380
-			$values[ $k ] = wp_kses_post( $val );
380
+			$values[$k] = wp_kses_post( $val );
381 381
 		}
382 382
 	}
383 383
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			$allowed_html = $html;
405 405
 		} elseif ( ! empty( $allowed ) ) {
406 406
 			foreach ( (array) $allowed as $a ) {
407
-				$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
407
+				$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
408 408
 			}
409 409
 		}
410 410
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
      * @since 2.0
502 502
      */
503 503
     public static function remove_get_action() {
504
-        if ( ! isset($_GET) ) {
504
+        if ( ! isset( $_GET ) ) {
505 505
             return;
506 506
         }
507 507
 
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
         }
524 524
 
525 525
         global $wp_query;
526
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
527
-            $value = $wp_query->query_vars[ $param ];
526
+        if ( isset( $wp_query->query_vars[$param] ) ) {
527
+            $value = $wp_query->query_vars[$param];
528 528
         }
529 529
 
530 530
         return $value;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 		return get_posts( array(
567 567
 			'post_type'   => 'page',
568 568
 			'post_status' => array( 'publish', 'private' ),
569
-			'numberposts' => -1,
569
+			'numberposts' => - 1,
570 570
 			'orderby'     => 'title',
571 571
 			'order'       => 'ASC',
572 572
 		) );
@@ -576,10 +576,10 @@  discard block
 block discarded – undo
576 576
         $pages = self::get_pages();
577 577
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
578 578
     ?>
579
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
579
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
580 580
             <option value=""> </option>
581 581
             <?php foreach ( $pages as $page ) { ?>
582
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
582
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
583 583
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
584 584
 				</option>
585 585
             <?php } ?>
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
     }
589 589
 
590 590
 	public static function post_edit_link( $post_id ) {
591
-        $post = get_post($post_id);
591
+        $post = get_post( $post_id );
592 592
         if ( $post ) {
593 593
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
594 594
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 
599 599
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
600 600
 		?>
601
-		<select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect">
601
+		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect">
602 602
 			<?php self::roles_options( $capability ); ?>
603 603
 		</select>
604 604
 		<?php
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
 	public static function roles_options( $capability ) {
608 608
         global $frm_vars;
609
-        if ( isset($frm_vars['editable_roles']) ) {
609
+        if ( isset( $frm_vars['editable_roles'] ) ) {
610 610
             $editable_roles = $frm_vars['editable_roles'];
611 611
         } else {
612 612
             $editable_roles = get_editable_roles();
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
         foreach ( $editable_roles as $role => $details ) {
617 617
 			$name = translate_user_role( $details['name'] );
618 618
 			?>
619
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
619
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
620 620
 <?php
621
-            unset($role, $details);
621
+            unset( $role, $details );
622 622
         }
623 623
     }
624 624
 
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
     public static function maybe_add_permissions() {
675 675
 		self::force_capability( 'frm_view_entries' );
676 676
 
677
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
677
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
678 678
             return;
679 679
         }
680 680
 
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
         $frm_roles = self::frm_capabilities();
684 684
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
685 685
 			$user->add_cap( $frm_role );
686
-            unset($frm_role, $frm_role_description);
686
+            unset( $frm_role, $frm_role_description );
687 687
         }
688 688
     }
689 689
 
@@ -708,12 +708,12 @@  discard block
 block discarded – undo
708 708
      * @param string $permission
709 709
      */
710 710
 	public static function permission_check( $permission, $show_message = 'show' ) {
711
-        $permission_error = self::permission_nonce_error($permission);
711
+        $permission_error = self::permission_nonce_error( $permission );
712 712
         if ( $permission_error !== false ) {
713 713
             if ( 'hide' == $show_message ) {
714 714
                 $permission_error = '';
715 715
             }
716
-            wp_die($permission_error);
716
+            wp_die( $permission_error );
717 717
         }
718 718
     }
719 719
 
@@ -730,11 +730,11 @@  discard block
 block discarded – undo
730 730
 		}
731 731
 
732 732
 		$error = false;
733
-        if ( empty($nonce_name) ) {
733
+        if ( empty( $nonce_name ) ) {
734 734
             return $error;
735 735
         }
736 736
 
737
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
737
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
738 738
             $frm_settings = self::get_settings();
739 739
             $error = $frm_settings->admin_permission;
740 740
         }
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 			} else {
815 815
 				foreach ( $value as $k => $v ) {
816 816
 					if ( ! is_array( $v ) ) {
817
-						$value[ $k ] = call_user_func( $original_function, $v );
817
+						$value[$k] = call_user_func( $original_function, $v );
818 818
 					}
819 819
 				}
820 820
 			}
@@ -835,11 +835,11 @@  discard block
 block discarded – undo
835 835
 	public static function array_flatten( $array, $keys = 'keep' ) {
836 836
         $return = array();
837 837
         foreach ( $array as $key => $value ) {
838
-            if ( is_array($value) ) {
838
+            if ( is_array( $value ) ) {
839 839
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
840 840
             } else {
841 841
 				if ( $keys == 'keep' ) {
842
-					$return[ $key ] = $value;
842
+					$return[$key] = $value;
843 843
 				} else {
844 844
 					$return[] = $value;
845 845
 				}
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
      * @since 2.0
863 863
      */
864 864
 	public static function use_wpautop( $content ) {
865
-        if ( apply_filters('frm_use_wpautop', true) ) {
866
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
865
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
866
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
867 867
         }
868 868
         return $content;
869 869
     }
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
      */
883 883
     public static function jquery_ui_base_url() {
884 884
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
885
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
885
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
886 886
         return $url;
887 887
     }
888 888
 
@@ -896,11 +896,11 @@  discard block
 block discarded – undo
896 896
 		}
897 897
 
898 898
 		$ver = $default;
899
-		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
899
+		if ( ! isset( $wp_scripts->registered[$handle] ) ) {
900 900
 			return $ver;
901 901
 		}
902 902
 
903
-		$query = $wp_scripts->registered[ $handle ];
903
+		$query = $wp_scripts->registered[$handle];
904 904
 		if ( is_object( $query ) && ! empty( $query->ver ) ) {
905 905
 			$ver = $query->ver;
906 906
 		}
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
     }
914 914
 
915 915
 	public static function get_user_id_param( $user_id ) {
916
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
916
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
917 917
             return $user_id;
918 918
         }
919 919
 
@@ -921,29 +921,29 @@  discard block
 block discarded – undo
921 921
 		if ( $user_id == 'current' ) {
922 922
 			$user_id = get_current_user_id();
923 923
 		} else {
924
-            if ( is_email($user_id) ) {
925
-                $user = get_user_by('email', $user_id);
924
+            if ( is_email( $user_id ) ) {
925
+                $user = get_user_by( 'email', $user_id );
926 926
             } else {
927
-                $user = get_user_by('login', $user_id);
927
+                $user = get_user_by( 'login', $user_id );
928 928
             }
929 929
 
930 930
             if ( $user ) {
931 931
                 $user_id = $user->ID;
932 932
             }
933
-            unset($user);
933
+            unset( $user );
934 934
         }
935 935
 
936 936
         return $user_id;
937 937
     }
938 938
 
939 939
 	public static function get_file_contents( $filename, $atts = array() ) {
940
-        if ( ! is_file($filename) ) {
940
+        if ( ! is_file( $filename ) ) {
941 941
             return false;
942 942
         }
943 943
 
944
-        extract($atts);
944
+        extract( $atts );
945 945
         ob_start();
946
-        include($filename);
946
+        include( $filename );
947 947
         $contents = ob_get_contents();
948 948
         ob_end_clean();
949 949
         return $contents;
@@ -959,16 +959,16 @@  discard block
 block discarded – undo
959 959
         $key = '';
960 960
 
961 961
         if ( ! empty( $name ) ) {
962
-            $key = sanitize_key($name);
962
+            $key = sanitize_key( $name );
963 963
         }
964 964
 
965 965
 		if ( empty( $key ) ) {
966
-            $max_slug_value = pow(36, $num_chars);
966
+            $max_slug_value = pow( 36, $num_chars );
967 967
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
968
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
968
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
969 969
         }
970 970
 
971
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
971
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
972 972
 			$key = $key . 'a';
973 973
         }
974 974
 
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 			'ID !'  => $id,
978 978
 		), $column );
979 979
 
980
-        if ( $key_check || is_numeric($key_check) ) {
980
+        if ( $key_check || is_numeric( $key_check ) ) {
981 981
             $suffix = 2;
982 982
 			do {
983 983
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 					$column => $alt_post_name,
986 986
 					'ID !'  => $id,
987 987
 				), $column );
988
-				$suffix++;
988
+				$suffix ++;
989 989
 			} while ( $key_check || is_numeric( $key_check ) );
990 990
 			$key = $alt_post_name;
991 991
         }
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
             return false;
1003 1003
         }
1004 1004
 
1005
-        if ( empty($post_values) ) {
1006
-            $post_values = stripslashes_deep($_POST);
1005
+        if ( empty( $post_values ) ) {
1006
+            $post_values = stripslashes_deep( $_POST );
1007 1007
         }
1008 1008
 
1009 1009
 		$values = array(
@@ -1012,25 +1012,25 @@  discard block
 block discarded – undo
1012 1012
 		);
1013 1013
 
1014 1014
 		foreach ( array( 'name', 'description' ) as $var ) {
1015
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
1016
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1017
-            unset($var, $default_val);
1015
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
1016
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1017
+            unset( $var, $default_val );
1018 1018
         }
1019 1019
 
1020
-        $values['description'] = self::use_wpautop($values['description']);
1020
+        $values['description'] = self::use_wpautop( $values['description'] );
1021 1021
         $frm_settings = self::get_settings();
1022
-        $is_form_builder = self::is_admin_page('formidable' );
1022
+        $is_form_builder = self::is_admin_page( 'formidable' );
1023 1023
 
1024 1024
         foreach ( (array) $fields as $field ) {
1025 1025
             // Make sure to filter default values (for placeholder text), but not on the form builder page
1026 1026
             if ( ! $is_form_builder ) {
1027
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1027
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
1028 1028
             }
1029 1029
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1030
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1030
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1031 1031
         }
1032 1032
 
1033
-        self::fill_form_opts($record, $table, $post_values, $values);
1033
+        self::fill_form_opts( $record, $table, $post_values, $values );
1034 1034
 
1035 1035
         if ( $table == 'entries' ) {
1036 1036
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
         if ( $args['default'] ) {
1048 1048
             $meta_value = $field->default_value;
1049 1049
         } else {
1050
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1051
-                if ( ! isset($field->field_options['custom_field']) ) {
1050
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1051
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1052 1052
                     $field->field_options['custom_field'] = '';
1053 1053
                 }
1054 1054
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
@@ -1062,8 +1062,8 @@  discard block
 block discarded – undo
1062 1062
             }
1063 1063
         }
1064 1064
 
1065
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1066
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1065
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1066
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1067 1067
 
1068 1068
         $field_array = array(
1069 1069
             'id'            => $field->id,
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
             'default_value' => $field->default_value,
1072 1072
             'name'          => $field->name,
1073 1073
             'description'   => $field->description,
1074
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1074
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1075 1075
             'options'       => $field->options,
1076 1076
             'required'      => $field->required,
1077 1077
             'field_key'     => $field->field_key,
@@ -1081,40 +1081,40 @@  discard block
 block discarded – undo
1081 1081
         );
1082 1082
 
1083 1083
         $args['field_type'] = $field_type;
1084
-        self::fill_field_opts($field, $field_array, $args);
1084
+        self::fill_field_opts( $field, $field_array, $args );
1085 1085
 		// Track the original field's type
1086 1086
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1087 1087
 
1088 1088
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1089 1089
 
1090
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1090
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1091 1091
             $field_array['unique_msg'] = '';
1092 1092
         }
1093 1093
 
1094 1094
         $field_array = array_merge( $field->field_options, $field_array );
1095 1095
 
1096
-        $values['fields'][ $field->id ] = $field_array;
1096
+        $values['fields'][$field->id] = $field_array;
1097 1097
     }
1098 1098
 
1099 1099
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1100 1100
         $post_values = $args['post_values'];
1101
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1101
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1102 1102
 
1103 1103
         foreach ( $opt_defaults as $opt => $default_opt ) {
1104
-			$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 );
1105
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1106
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1107
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1104
+			$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 );
1105
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1106
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1107
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1108 1108
                 if ( $args['field_type'] == 'captcha' ) {
1109
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1109
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1110 1110
                 } else {
1111
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1111
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1112 1112
                 }
1113 1113
             }
1114 1114
         }
1115 1115
 
1116 1116
         if ( $field_array['custom_html'] == '' ) {
1117
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1117
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1118 1118
         }
1119 1119
     }
1120 1120
 
@@ -1133,18 +1133,18 @@  discard block
 block discarded – undo
1133 1133
             return;
1134 1134
         }
1135 1135
 
1136
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1136
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1137 1137
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1138 1138
 
1139
-        if ( ! is_array($form->options) ) {
1139
+        if ( ! is_array( $form->options ) ) {
1140 1140
             return;
1141 1141
         }
1142 1142
 
1143 1143
         foreach ( $form->options as $opt => $value ) {
1144
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1144
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1145 1145
         }
1146 1146
 
1147
-        self::fill_form_defaults($post_values, $values);
1147
+        self::fill_form_defaults( $post_values, $values );
1148 1148
     }
1149 1149
 
1150 1150
     /**
@@ -1154,11 +1154,11 @@  discard block
 block discarded – undo
1154 1154
         $form_defaults = FrmFormsHelper::get_default_opts();
1155 1155
 
1156 1156
         foreach ( $form_defaults as $opt => $default ) {
1157
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1158
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1157
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1158
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1159 1159
             }
1160 1160
 
1161
-            unset($opt, $defaut);
1161
+            unset( $opt, $defaut );
1162 1162
         }
1163 1163
 
1164 1164
 		if ( ! isset( $values['custom_style'] ) ) {
@@ -1166,10 +1166,10 @@  discard block
 block discarded – undo
1166 1166
 		}
1167 1167
 
1168 1168
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1169
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1170
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1169
+			if ( ! isset( $values[$h . '_html'] ) ) {
1170
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1171 1171
             }
1172
-            unset($h);
1172
+            unset( $h );
1173 1173
         }
1174 1174
     }
1175 1175
 
@@ -1200,9 +1200,9 @@  discard block
 block discarded – undo
1200 1200
         }
1201 1201
     ?>
1202 1202
 <li>
1203
-    <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>
1204
-    <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>
1205
-    <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>
1203
+    <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>
1204
+    <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>
1205
+    <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>
1206 1206
 </li>
1207 1207
     <?php
1208 1208
     }
@@ -1231,18 +1231,18 @@  discard block
 block discarded – undo
1231 1231
 		foreach ( $words as $word ) {
1232 1232
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1233 1233
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1234
-            if ( $total_len > $length && str_word_count($sub) ) {
1234
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1235 1235
                 break;
1236 1236
             }
1237 1237
 
1238 1238
             $sub .= $part;
1239 1239
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1240 1240
 
1241
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1241
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1242 1242
                 break;
1243 1243
             }
1244 1244
 
1245
-            unset($total_len, $word);
1245
+            unset( $total_len, $word );
1246 1246
         }
1247 1247
 
1248 1248
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
@@ -1258,17 +1258,17 @@  discard block
 block discarded – undo
1258 1258
 	}
1259 1259
 
1260 1260
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1261
-        if ( empty($date) ) {
1261
+        if ( empty( $date ) ) {
1262 1262
             return $date;
1263 1263
         }
1264 1264
 
1265
-        if ( empty($date_format) ) {
1266
-            $date_format = get_option('date_format');
1265
+        if ( empty( $date_format ) ) {
1266
+            $date_format = get_option( 'date_format' );
1267 1267
         }
1268 1268
 
1269
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1269
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1270 1270
             $frmpro_settings = new FrmProSettings();
1271
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1271
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1272 1272
         }
1273 1273
 
1274 1274
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 
1284 1284
 	private static function add_time_to_date( $time_format, $date ) {
1285 1285
 		if ( empty( $time_format ) ) {
1286
-			$time_format = get_option('time_format');
1286
+			$time_format = get_option( 'time_format' );
1287 1287
 		}
1288 1288
 
1289 1289
 		$trimmed_format = trim( $time_format );
@@ -1329,10 +1329,10 @@  discard block
 block discarded – undo
1329 1329
 		$time_strings = self::get_time_strings();
1330 1330
 
1331 1331
 		foreach ( $time_strings as $k => $v ) {
1332
-			if ( $diff[ $k ] ) {
1333
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1332
+			if ( $diff[$k] ) {
1333
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1334 1334
 			} else {
1335
-				unset( $time_strings[ $k ] );
1335
+				unset( $time_strings[$k] );
1336 1336
 			}
1337 1337
 		}
1338 1338
 
@@ -1387,19 +1387,19 @@  discard block
 block discarded – undo
1387 1387
 	public static function json_to_array( $json_vars ) {
1388 1388
         $vars = array();
1389 1389
         foreach ( $json_vars as $jv ) {
1390
-            $jv_name = explode('[', $jv['name']);
1391
-            $last = count($jv_name) - 1;
1390
+            $jv_name = explode( '[', $jv['name'] );
1391
+            $last = count( $jv_name ) - 1;
1392 1392
             foreach ( $jv_name as $p => $n ) {
1393
-                $name = trim($n, ']');
1394
-                if ( ! isset($l1) ) {
1393
+                $name = trim( $n, ']' );
1394
+                if ( ! isset( $l1 ) ) {
1395 1395
                     $l1 = $name;
1396 1396
                 }
1397 1397
 
1398
-                if ( ! isset($l2) ) {
1398
+                if ( ! isset( $l2 ) ) {
1399 1399
                     $l2 = $name;
1400 1400
                 }
1401 1401
 
1402
-                if ( ! isset($l3) ) {
1402
+                if ( ! isset( $l3 ) ) {
1403 1403
                     $l3 = $name;
1404 1404
                 }
1405 1405
 
@@ -1413,23 +1413,23 @@  discard block
 block discarded – undo
1413 1413
 
1414 1414
                     case 1:
1415 1415
                         $l2 = $name;
1416
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1416
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1417 1417
 						break;
1418 1418
 
1419 1419
                     case 2:
1420 1420
                         $l3 = $name;
1421
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1421
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1422 1422
 						break;
1423 1423
 
1424 1424
                     case 3:
1425 1425
                         $l4 = $name;
1426
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1426
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1427 1427
                 }
1428 1428
 
1429
-                unset($this_val, $n);
1429
+                unset( $this_val, $n );
1430 1430
             }
1431 1431
 
1432
-            unset($last, $jv);
1432
+            unset( $last, $jv );
1433 1433
         }
1434 1434
 
1435 1435
         return $vars;
@@ -1442,8 +1442,8 @@  discard block
 block discarded – undo
1442 1442
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1443 1443
         if ( $name == '' ) {
1444 1444
             $vars[] = $val;
1445
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1446
-            $vars[ $l1 ] = $val;
1445
+        } else if ( ! isset( $vars[$l1] ) ) {
1446
+            $vars[$l1] = $val;
1447 1447
         }
1448 1448
     }
1449 1449
 
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
             '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() ) ),
1459 1459
         );
1460 1460
 
1461
-        if ( ! isset( $tooltips[ $name ] ) ) {
1461
+        if ( ! isset( $tooltips[$name] ) ) {
1462 1462
             return;
1463 1463
         }
1464 1464
 
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
             echo ' class="frm_help"';
1469 1469
         }
1470 1470
 
1471
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1471
+		echo ' title="' . esc_attr( $tooltips[$name] );
1472 1472
 
1473 1473
         if ( 'open' != $class ) {
1474 1474
             echo '"';
@@ -1520,13 +1520,13 @@  discard block
 block discarded – undo
1520 1520
     }
1521 1521
 
1522 1522
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1523
-		if ( ! isset( $post_content[ $key ] ) ) {
1523
+		if ( ! isset( $post_content[$key] ) ) {
1524 1524
 			return;
1525 1525
 		}
1526 1526
 
1527 1527
 		if ( is_array( $val ) ) {
1528 1528
 			foreach ( $val as $k1 => $v1 ) {
1529
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1529
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1530 1530
 				unset( $k1, $v1 );
1531 1531
 			}
1532 1532
 		} else {
@@ -1534,22 +1534,22 @@  discard block
 block discarded – undo
1534 1534
 			$val = stripslashes( $val );
1535 1535
 
1536 1536
 			// Add backslashes before double quotes and forward slashes only
1537
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1537
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1538 1538
 		}
1539 1539
 	}
1540 1540
 
1541 1541
 	public static function maybe_json_decode( $string ) {
1542
-        if ( is_array($string) ) {
1542
+        if ( is_array( $string ) ) {
1543 1543
             return $string;
1544 1544
         }
1545 1545
 
1546
-        $new_string = json_decode($string, true);
1547
-        if ( function_exists('json_last_error') ) {
1546
+        $new_string = json_decode( $string, true );
1547
+        if ( function_exists( 'json_last_error' ) ) {
1548 1548
 			// php 5.3+
1549 1549
             if ( json_last_error() == JSON_ERROR_NONE ) {
1550 1550
                 $string = $new_string;
1551 1551
             }
1552
-        } else if ( isset($new_string) ) {
1552
+        } else if ( isset( $new_string ) ) {
1553 1553
 			// php < 5.3 fallback
1554 1554
             $string = $new_string;
1555 1555
         }
@@ -1565,11 +1565,11 @@  discard block
 block discarded – undo
1565 1565
 	public static function maybe_highlight_menu( $post_type ) {
1566 1566
         global $post;
1567 1567
 
1568
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1568
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1569 1569
             return;
1570 1570
         }
1571 1571
 
1572
-        if ( is_object($post) && $post->post_type != $post_type ) {
1572
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1573 1573
             return;
1574 1574
         }
1575 1575
 
@@ -1673,11 +1673,11 @@  discard block
 block discarded – undo
1673 1673
         $frm_version = self::plugin_version();
1674 1674
 
1675 1675
         // check if Formidable meets minimum requirements
1676
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1676
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1677 1677
             return;
1678 1678
         }
1679 1679
 
1680
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1680
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1681 1681
 		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">' .
1682 1682
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1683 1683
         '</div></td></tr>';
@@ -1759,8 +1759,8 @@  discard block
 block discarded – undo
1759 1759
 			$unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' );
1760 1760
 		}
1761 1761
 
1762
-        $locales = array_diff_key($locales, array_flip($unset));
1763
-        $locales = apply_filters('frm_locales', $locales);
1762
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1763
+        $locales = apply_filters( 'frm_locales', $locales );
1764 1764
 
1765 1765
         return $locales;
1766 1766
     }
Please login to merge, or discard this patch.