Completed
Push — master ( dd640d...c833ab )
by Jamie
08:54 queued 05:29
created
classes/helpers/FrmAppHelper.php 1 patch
Spacing   +223 added lines, -223 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,16 +23,16 @@  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() {
34 34
         //prevously FRM_URL constant
35
-        return plugins_url( '', self::plugin_path() .'/formidable.php' );
35
+        return plugins_url( '', self::plugin_path() . '/formidable.php' );
36 36
     }
37 37
 
38 38
 	public static function relative_plugin_url() {
@@ -54,12 +54,12 @@  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 ) {
61 61
 		$affiliate_id = apply_filters( 'frm_affiliate_link', '' );
62
-		$allowed_affiliates = array('Mojo');
62
+		$allowed_affiliates = array( 'Mojo' );
63 63
 		if ( in_array( $affiliate_id, $allowed_affiliates ) ) {
64 64
 			$url .= '?aff=' . $affiliate_id;
65 65
 		}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public static function get_settings() {
78 78
         global $frm_settings;
79
-        if ( empty($frm_settings) ) {
79
+        if ( empty( $frm_settings ) ) {
80 80
             $frm_settings = new FrmSettings();
81 81
         }
82 82
         return $frm_settings;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     }
93 93
 
94 94
     public static function pro_is_installed() {
95
-        return apply_filters('frm_pro_installed', false);
95
+        return apply_filters( 'frm_pro_installed', false );
96 96
     }
97 97
 
98 98
     /**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      * @return boolean
137 137
      */
138 138
     public static function doing_ajax() {
139
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
139
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
140 140
     }
141 141
 
142 142
 	/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      * @return boolean
157 157
      */
158 158
     public static function is_admin() {
159
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
159
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
160 160
     }
161 161
 
162 162
     /**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      * @return string
183 183
      */
184 184
 	public static function get_server_value( $value ) {
185
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
185
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
186 186
     }
187 187
 
188 188
     /**
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
198 198
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
199 199
         ) as $key ) {
200
-            if ( ! isset( $_SERVER[ $key ] ) ) {
200
+            if ( ! isset( $_SERVER[$key] ) ) {
201 201
                 continue;
202 202
             }
203 203
 
204
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
205
-                $ip = trim($ip); // just to be safe
204
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
205
+                $ip = trim( $ip ); // just to be safe
206 206
 
207
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
207
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
208 208
                     return $ip;
209 209
                 }
210 210
             }
@@ -214,15 +214,15 @@  discard block
 block discarded – undo
214 214
     }
215 215
 
216 216
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
217
-        if ( strpos($param, '[') ) {
218
-            $params = explode('[', $param);
217
+        if ( strpos( $param, '[' ) ) {
218
+            $params = explode( '[', $param );
219 219
             $param = $params[0];
220 220
         }
221 221
 
222 222
 		if ( $src == 'get' ) {
223
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
224
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
225
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
223
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
224
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
225
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
226 226
             }
227 227
 			self::sanitize_value( $sanitize, $value );
228 228
 		} else {
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 
232 232
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
233 233
             foreach ( $params as $k => $p ) {
234
-                if ( ! $k || ! is_array($value) ) {
234
+                if ( ! $k || ! is_array( $value ) ) {
235 235
                     continue;
236 236
                 }
237 237
 
238
-                $p = trim($p, ']');
239
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
238
+                $p = trim( $p, ']' );
239
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
240 240
             }
241 241
         }
242 242
 
@@ -278,16 +278,16 @@  discard block
 block discarded – undo
278 278
 
279 279
 		$value = $args['default'];
280 280
 		if ( $args['type'] == 'get' ) {
281
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
282
-				$value = $_GET[ $args['param'] ];
281
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
282
+				$value = $_GET[$args['param']];
283 283
 			}
284 284
 		} else if ( $args['type'] == 'post' ) {
285
-			if ( isset( $_POST[ $args['param'] ] ) ) {
286
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
285
+			if ( isset( $_POST[$args['param']] ) ) {
286
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
287 287
 			}
288 288
 		} else {
289
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
290
-				$value = $_REQUEST[ $args['param'] ];
289
+			if ( isset( $_REQUEST[$args['param']] ) ) {
290
+				$value = $_REQUEST[$args['param']];
291 291
 			}
292 292
 		}
293 293
 
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
     public static function sanitize_request( $sanitize_method, &$values ) {
324 324
         $temp_values = $values;
325 325
         foreach ( $temp_values as $k => $val ) {
326
-            if ( isset( $sanitize_method[ $k ] ) ) {
327
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
326
+            if ( isset( $sanitize_method[$k] ) ) {
327
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
328 328
             }
329 329
         }
330 330
     }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	public static function sanitize_array( &$values ) {
333 333
 		$temp_values = $values;
334 334
 		foreach ( $temp_values as $k => $val ) {
335
-			$values[ $k ] = wp_kses_post( $val );
335
+			$values[$k] = wp_kses_post( $val );
336 336
 		}
337 337
 	}
338 338
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
 		$allowed_html = array();
354 354
 		foreach ( $allowed as $a ) {
355
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
355
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
356 356
 		}
357 357
 
358 358
 		return wp_kses( $value, $allowed_html );
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
      * @since 2.0
364 364
      */
365 365
     public static function remove_get_action() {
366
-        if ( ! isset($_GET) ) {
366
+        if ( ! isset( $_GET ) ) {
367 367
             return;
368 368
         }
369 369
 
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
         }
386 386
 
387 387
         global $wp_query;
388
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
389
-            $value = $wp_query->query_vars[ $param ];
388
+        if ( isset( $wp_query->query_vars[$param] ) ) {
389
+            $value = $wp_query->query_vars[$param];
390 390
         }
391 391
 
392 392
         return $value;
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
      */
398 398
     public static function trigger_hook_load( $type, $object = null ) {
399 399
         // only load the form hooks once
400
-        $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
400
+        $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
401 401
         if ( ! $hooks_loaded ) {
402
-            do_action('frm_load_'. $type .'_hooks');
402
+            do_action( 'frm_load_' . $type . '_hooks' );
403 403
         }
404 404
     }
405 405
 
@@ -415,16 +415,16 @@  discard block
 block discarded – undo
415 415
      * @return mixed $results The cache or query results
416 416
      */
417 417
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
418
-        $results = wp_cache_get($cache_key, $group);
419
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
418
+        $results = wp_cache_get( $cache_key, $group );
419
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
420 420
             return $results;
421 421
         }
422 422
 
423 423
         if ( 'get_posts' == $type ) {
424
-            $results = get_posts($query);
424
+            $results = get_posts( $query );
425 425
         } else {
426 426
             global $wpdb;
427
-            $results = $wpdb->{$type}($query);
427
+            $results = $wpdb->{$type}( $query );
428 428
         }
429 429
 
430 430
 		if ( ! self::prevent_caching() ) {
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
         }
449 449
 
450 450
         // then check the transient
451
-        $results = get_transient($cache_key);
451
+        $results = get_transient( $cache_key );
452 452
         if ( $results ) {
453
-            wp_cache_set($cache_key, $results);
453
+            wp_cache_set( $cache_key, $results );
454 454
         }
455 455
 
456 456
         return $results;
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
      * @param string $cache_key
462 462
      */
463 463
 	public static function delete_cache_and_transient( $cache_key ) {
464
-        delete_transient($cache_key);
465
-        wp_cache_delete($cache_key);
464
+        delete_transient( $cache_key );
465
+        wp_cache_delete( $cache_key );
466 466
     }
467 467
 
468 468
     /**
@@ -476,9 +476,9 @@  discard block
 block discarded – undo
476 476
 	public static function cache_delete_group( $group ) {
477 477
     	global $wp_object_cache;
478 478
 
479
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
480
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
481
-                wp_cache_delete($k, $group);
479
+        if ( isset( $wp_object_cache->cache[$group] ) ) {
480
+            foreach ( $wp_object_cache->cache[$group] as $k => $v ) {
481
+                wp_cache_delete( $k, $group );
482 482
             }
483 483
             return true;
484 484
         }
@@ -509,29 +509,29 @@  discard block
 block discarded – undo
509 509
 	public static function load_scripts( $scripts ) {
510 510
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
511 511
         foreach ( (array) $scripts as $s ) {
512
-            wp_enqueue_script($s);
512
+            wp_enqueue_script( $s );
513 513
         }
514 514
     }
515 515
 
516 516
 	public static function load_styles( $styles ) {
517 517
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
518 518
         foreach ( (array) $styles as $s ) {
519
-            wp_enqueue_style($s);
519
+            wp_enqueue_style( $s );
520 520
         }
521 521
     }
522 522
 
523 523
     public static function get_pages() {
524
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
524
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
525 525
     }
526 526
 
527 527
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
528 528
         $pages = self::get_pages();
529 529
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
530 530
     ?>
531
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
531
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
532 532
             <option value=""> </option>
533 533
             <?php foreach ( $pages as $page ) { ?>
534
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
534
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
535 535
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
536 536
 				</option>
537 537
             <?php } ?>
@@ -540,26 +540,26 @@  discard block
 block discarded – undo
540 540
     }
541 541
 
542 542
 	public static function post_edit_link( $post_id ) {
543
-        $post = get_post($post_id);
543
+        $post = get_post( $post_id );
544 544
         if ( $post ) {
545
-            return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
545
+            return '<a href="' . esc_url( admin_url( 'post.php' ) . '?post=' . $post_id . '&action=edit' ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
546 546
         }
547 547
         return '';
548 548
     }
549 549
 
550 550
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
551 551
     ?>
552
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
552
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
553 553
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
554 554
             ?> class="frm_multiselect">
555
-            <?php self::roles_options($capability); ?>
555
+            <?php self::roles_options( $capability ); ?>
556 556
         </select>
557 557
     <?php
558 558
     }
559 559
 
560 560
 	public static function roles_options( $capability ) {
561 561
         global $frm_vars;
562
-        if ( isset($frm_vars['editable_roles']) ) {
562
+        if ( isset( $frm_vars['editable_roles'] ) ) {
563 563
             $editable_roles = $frm_vars['editable_roles'];
564 564
         } else {
565 565
             $editable_roles = get_editable_roles();
@@ -567,10 +567,10 @@  discard block
 block discarded – undo
567 567
         }
568 568
 
569 569
         foreach ( $editable_roles as $role => $details ) {
570
-            $name = translate_user_role($details['name'] ); ?>
571
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
570
+            $name = translate_user_role( $details['name'] ); ?>
571
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
572 572
 <?php
573
-            unset($role, $details);
573
+            unset( $role, $details );
574 574
         }
575 575
     }
576 576
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
     public static function maybe_add_permissions() {
627 627
 		self::force_capability( 'frm_view_entries' );
628 628
 
629
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
629
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
630 630
             return;
631 631
         }
632 632
 
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
         $frm_roles = self::frm_capabilities();
636 636
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
637 637
 			$user->add_cap( $frm_role );
638
-            unset($frm_role, $frm_role_description);
638
+            unset( $frm_role, $frm_role_description );
639 639
         }
640 640
     }
641 641
 
@@ -660,12 +660,12 @@  discard block
 block discarded – undo
660 660
      * @param string $permission
661 661
      */
662 662
 	public static function permission_check( $permission, $show_message = 'show' ) {
663
-        $permission_error = self::permission_nonce_error($permission);
663
+        $permission_error = self::permission_nonce_error( $permission );
664 664
         if ( $permission_error !== false ) {
665 665
             if ( 'hide' == $show_message ) {
666 666
                 $permission_error = '';
667 667
             }
668
-            wp_die($permission_error);
668
+            wp_die( $permission_error );
669 669
         }
670 670
     }
671 671
 
@@ -682,11 +682,11 @@  discard block
 block discarded – undo
682 682
 		}
683 683
 
684 684
 		$error = false;
685
-        if ( empty($nonce_name) ) {
685
+        if ( empty( $nonce_name ) ) {
686 686
             return $error;
687 687
         }
688 688
 
689
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
689
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
690 690
             $frm_settings = self::get_settings();
691 691
             $error = $frm_settings->admin_permission;
692 692
         }
@@ -702,9 +702,9 @@  discard block
 block discarded – undo
702 702
 
703 703
 	public static function check_selected( $values, $current ) {
704 704
         $values = self::recursive_function_map( $values, 'trim' );
705
-        $current = trim($current);
705
+        $current = trim( $current );
706 706
 
707
-        return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
707
+        return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
708 708
     }
709 709
 
710 710
     /**
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 			} else {
766 766
 				foreach ( $value as $k => $v ) {
767 767
 					if ( ! is_array( $v ) ) {
768
-						$value[ $k ] = call_user_func( $original_function, $v );
768
+						$value[$k] = call_user_func( $original_function, $v );
769 769
 					}
770 770
 				}
771 771
 			}
@@ -786,11 +786,11 @@  discard block
 block discarded – undo
786 786
 	public static function array_flatten( $array, $keys = 'keep' ) {
787 787
         $return = array();
788 788
         foreach ( $array as $key => $value ) {
789
-            if ( is_array($value) ) {
789
+            if ( is_array( $value ) ) {
790 790
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
791 791
             } else {
792 792
 				if ( $keys == 'keep' ) {
793
-					$return[ $key ] = $value;
793
+					$return[$key] = $value;
794 794
 				} else {
795 795
 					$return[] = $value;
796 796
 				}
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
     }
801 801
 
802 802
     public static function esc_textarea( $text ) {
803
-        $safe_text = str_replace('&quot;', '"', $text);
803
+        $safe_text = str_replace( '&quot;', '"', $text );
804 804
         $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
805 805
     	return apply_filters( 'esc_textarea', $safe_text, $text );
806 806
     }
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
      * @since 2.0
811 811
      */
812 812
 	public static function use_wpautop( $content ) {
813
-        if ( apply_filters('frm_use_wpautop', true) ) {
814
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
813
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
814
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
815 815
         }
816 816
         return $content;
817 817
     }
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
      * @return string The base Google APIS url for the current version of jQuery UI
830 830
      */
831 831
     public static function jquery_ui_base_url() {
832
-        $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
833
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
832
+        $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
833
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
834 834
         return $url;
835 835
     }
836 836
 
@@ -845,11 +845,11 @@  discard block
 block discarded – undo
845 845
 
846 846
         $ver = 0;
847 847
 
848
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
848
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
849 849
             return $ver;
850 850
         }
851 851
 
852
-        $query = $wp_scripts->registered[ $handle ];
852
+        $query = $wp_scripts->registered[$handle];
853 853
     	if ( is_object( $query ) ) {
854 854
     	    $ver = $query->ver;
855 855
     	}
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
     }
863 863
 
864 864
 	public static function get_user_id_param( $user_id ) {
865
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
865
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
866 866
             return $user_id;
867 867
         }
868 868
 
@@ -870,29 +870,29 @@  discard block
 block discarded – undo
870 870
             $user_ID = get_current_user_id();
871 871
             $user_id = $user_ID;
872 872
 		} else {
873
-            if ( is_email($user_id) ) {
874
-                $user = get_user_by('email', $user_id);
873
+            if ( is_email( $user_id ) ) {
874
+                $user = get_user_by( 'email', $user_id );
875 875
             } else {
876
-                $user = get_user_by('login', $user_id);
876
+                $user = get_user_by( 'login', $user_id );
877 877
             }
878 878
 
879 879
             if ( $user ) {
880 880
                 $user_id = $user->ID;
881 881
             }
882
-            unset($user);
882
+            unset( $user );
883 883
         }
884 884
 
885 885
         return $user_id;
886 886
     }
887 887
 
888 888
 	public static function get_file_contents( $filename, $atts = array() ) {
889
-        if ( ! is_file($filename) ) {
889
+        if ( ! is_file( $filename ) ) {
890 890
             return false;
891 891
         }
892 892
 
893
-        extract($atts);
893
+        extract( $atts );
894 894
         ob_start();
895
-        include($filename);
895
+        include( $filename );
896 896
         $contents = ob_get_contents();
897 897
         ob_end_clean();
898 898
         return $contents;
@@ -908,28 +908,28 @@  discard block
 block discarded – undo
908 908
         $key = '';
909 909
 
910 910
         if ( ! empty( $name ) ) {
911
-            $key = sanitize_key($name);
911
+            $key = sanitize_key( $name );
912 912
         }
913 913
 
914 914
 		if ( empty( $key ) ) {
915
-            $max_slug_value = pow(36, $num_chars);
915
+            $max_slug_value = pow( 36, $num_chars );
916 916
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
917
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
917
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
918 918
         }
919 919
 
920
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
921
-            $key = $key .'a';
920
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
921
+            $key = $key . 'a';
922 922
         }
923 923
 
924 924
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
925 925
 
926
-        if ( $key_check || is_numeric($key_check) ) {
926
+        if ( $key_check || is_numeric( $key_check ) ) {
927 927
             $suffix = 2;
928 928
 			do {
929 929
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
930 930
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
931
-				$suffix++;
932
-			} while ($key_check || is_numeric($key_check));
931
+				$suffix ++;
932
+			} while ( $key_check || is_numeric( $key_check ) );
933 933
 			$key = $alt_post_name;
934 934
         }
935 935
         return $key;
@@ -947,32 +947,32 @@  discard block
 block discarded – undo
947 947
 
948 948
         global $frm_vars;
949 949
 
950
-        if ( empty($post_values) ) {
951
-            $post_values = stripslashes_deep($_POST);
950
+        if ( empty( $post_values ) ) {
951
+            $post_values = stripslashes_deep( $_POST );
952 952
         }
953 953
 
954 954
 		$values = array( 'id' => $record->id, 'fields' => array() );
955 955
 
956 956
 		foreach ( array( 'name', 'description' ) as $var ) {
957
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
958
-            $values[ $var ] = self::get_param( $var, $default_val );
959
-            unset($var, $default_val);
957
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
958
+            $values[$var] = self::get_param( $var, $default_val );
959
+            unset( $var, $default_val );
960 960
         }
961 961
 
962
-        $values['description'] = self::use_wpautop($values['description']);
962
+        $values['description'] = self::use_wpautop( $values['description'] );
963 963
         $frm_settings = self::get_settings();
964
-        $is_form_builder = self::is_admin_page('formidable' );
964
+        $is_form_builder = self::is_admin_page( 'formidable' );
965 965
 
966 966
         foreach ( (array) $fields as $field ) {
967 967
             // Make sure to filter default values (for placeholder text), but not on the form builder page
968 968
             if ( ! $is_form_builder ) {
969
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
969
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
970 970
             }
971 971
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
972
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
972
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
973 973
         }
974 974
 
975
-        self::fill_form_opts($record, $table, $post_values, $values);
975
+        self::fill_form_opts( $record, $table, $post_values, $values );
976 976
 
977 977
         if ( $table == 'entries' ) {
978 978
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
         if ( $args['default'] ) {
990 990
             $meta_value = $field->default_value;
991 991
         } else {
992
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
993
-                if ( ! isset($field->field_options['custom_field']) ) {
992
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
993
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
994 994
                     $field->field_options['custom_field'] = '';
995 995
                 }
996 996
 				$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 ) );
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
             }
1000 1000
         }
1001 1001
 
1002
-        $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
1003
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1002
+        $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1003
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1004 1004
 
1005 1005
         $field_array = array(
1006 1006
             'id'            => $field->id,
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
             'default_value' => $field->default_value,
1009 1009
             'name'          => $field->name,
1010 1010
             'description'   => $field->description,
1011
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1011
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1012 1012
             'options'       => $field->options,
1013 1013
             'required'      => $field->required,
1014 1014
             'field_key'     => $field->field_key,
@@ -1018,38 +1018,38 @@  discard block
 block discarded – undo
1018 1018
         );
1019 1019
 
1020 1020
         $args['field_type'] = $field_type;
1021
-        self::fill_field_opts($field, $field_array, $args);
1021
+        self::fill_field_opts( $field, $field_array, $args );
1022 1022
 
1023
-        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1023
+        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] );
1024 1024
 
1025
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1025
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1026 1026
             $field_array['unique_msg'] = '';
1027 1027
         }
1028 1028
 
1029 1029
         $field_array = array_merge( $field->field_options, $field_array );
1030 1030
 
1031
-        $values['fields'][ $field->id ] = $field_array;
1031
+        $values['fields'][$field->id] = $field_array;
1032 1032
     }
1033 1033
 
1034 1034
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1035 1035
         $post_values = $args['post_values'];
1036
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1036
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1037 1037
 
1038 1038
         foreach ( $opt_defaults as $opt => $default_opt ) {
1039
-            $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 );
1040
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1041
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1042
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1039
+            $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 );
1040
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1041
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1042
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1043 1043
                 if ( $args['field_type'] == 'captcha' ) {
1044
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1044
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1045 1045
                 } else {
1046
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1046
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1047 1047
                 }
1048 1048
             }
1049 1049
         }
1050 1050
 
1051 1051
         if ( $field_array['custom_html'] == '' ) {
1052
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1052
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1053 1053
         }
1054 1054
     }
1055 1055
 
@@ -1068,18 +1068,18 @@  discard block
 block discarded – undo
1068 1068
             return;
1069 1069
         }
1070 1070
 
1071
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1071
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1072 1072
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1073 1073
 
1074
-        if ( ! is_array($form->options) ) {
1074
+        if ( ! is_array( $form->options ) ) {
1075 1075
             return;
1076 1076
         }
1077 1077
 
1078 1078
         foreach ( $form->options as $opt => $value ) {
1079
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1079
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1080 1080
         }
1081 1081
 
1082
-        self::fill_form_defaults($post_values, $values);
1082
+        self::fill_form_defaults( $post_values, $values );
1083 1083
     }
1084 1084
 
1085 1085
     /**
@@ -1089,23 +1089,23 @@  discard block
 block discarded – undo
1089 1089
         $form_defaults = FrmFormsHelper::get_default_opts();
1090 1090
 
1091 1091
         foreach ( $form_defaults as $opt => $default ) {
1092
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1093
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1092
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1093
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1094 1094
             }
1095 1095
 
1096
-            unset($opt, $defaut);
1096
+            unset( $opt, $defaut );
1097 1097
         }
1098 1098
 
1099
-        if ( ! isset($values['custom_style']) ) {
1099
+        if ( ! isset( $values['custom_style'] ) ) {
1100 1100
             $frm_settings = self::get_settings();
1101 1101
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1102 1102
         }
1103 1103
 
1104 1104
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1105
-            if ( ! isset( $values[ $h .'_html' ] ) ) {
1106
-                $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1105
+            if ( ! isset( $values[$h . '_html'] ) ) {
1106
+                $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1107 1107
             }
1108
-            unset($h);
1108
+            unset( $h );
1109 1109
         }
1110 1110
     }
1111 1111
 
@@ -1121,9 +1121,9 @@  discard block
 block discarded – undo
1121 1121
         }
1122 1122
     ?>
1123 1123
 <li>
1124
-    <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>
1125
-    <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>
1126
-    <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>
1124
+    <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>
1125
+    <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>
1126
+    <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>
1127 1127
 </li>
1128 1128
     <?php
1129 1129
     }
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
             return '';
1152 1152
         } else if ( $length <= 10 ) {
1153 1153
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1154
-            return $sub . (($length < $original_len) ? $continue : '');
1154
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1155 1155
         }
1156 1156
 
1157 1157
         $sub = '';
@@ -1160,23 +1160,23 @@  discard block
 block discarded – undo
1160 1160
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1161 1161
 
1162 1162
 		foreach ( $words as $word ) {
1163
-            $part = (($sub != '') ? ' ' : '') . $word;
1163
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1164 1164
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1165
-            if ( $total_len > $length && str_word_count($sub) ) {
1165
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1166 1166
                 break;
1167 1167
             }
1168 1168
 
1169 1169
             $sub .= $part;
1170 1170
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1171 1171
 
1172
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1172
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1173 1173
                 break;
1174 1174
             }
1175 1175
 
1176
-            unset($total_len, $word);
1176
+            unset( $total_len, $word );
1177 1177
         }
1178 1178
 
1179
-        return $sub . (($len < $original_len) ? $continue : '');
1179
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1180 1180
     }
1181 1181
 
1182 1182
 	public static function mb_function( $function_names, $args ) {
@@ -1189,17 +1189,17 @@  discard block
 block discarded – undo
1189 1189
 	}
1190 1190
 
1191 1191
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1192
-        if ( empty($date) ) {
1192
+        if ( empty( $date ) ) {
1193 1193
             return $date;
1194 1194
         }
1195 1195
 
1196
-        if ( empty($date_format) ) {
1197
-            $date_format = get_option('date_format');
1196
+        if ( empty( $date_format ) ) {
1197
+            $date_format = get_option( 'date_format' );
1198 1198
         }
1199 1199
 
1200
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1200
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1201 1201
             $frmpro_settings = new FrmProSettings();
1202
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1202
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1203 1203
         }
1204 1204
 
1205 1205
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
 
1215 1215
 	private static function add_time_to_date( $time_format, $date ) {
1216 1216
 		if ( empty( $time_format ) ) {
1217
-			$time_format = get_option('time_format');
1217
+			$time_format = get_option( 'time_format' );
1218 1218
 		}
1219 1219
 
1220 1220
 		$trimmed_format = trim( $time_format );
@@ -1257,9 +1257,9 @@  discard block
 block discarded – undo
1257 1257
 
1258 1258
 		foreach ( $time_strings as $k => $v ) {
1259 1259
 			if ( $diff->$k ) {
1260
-				$time_strings[ $k ] = $diff->$k . ' ' . ( $diff->$k > 1 ? $v[1] : $v[0] );
1260
+				$time_strings[$k] = $diff->$k . ' ' . ( $diff->$k > 1 ? $v[1] : $v[0] );
1261 1261
 			} else {
1262
-				unset( $time_strings[ $k ] );
1262
+				unset( $time_strings[$k] );
1263 1263
 			}
1264 1264
 		}
1265 1265
 
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
      */
1298 1298
 	public static function esc_like( $term ) {
1299 1299
         global $wpdb;
1300
-        if ( method_exists($wpdb, 'esc_like') ) {
1300
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1301 1301
 			// WP 4.0
1302 1302
             $term = $wpdb->esc_like( $term );
1303 1303
         } else {
@@ -1311,17 +1311,17 @@  discard block
 block discarded – undo
1311 1311
      * @param string $order_query
1312 1312
      */
1313 1313
 	public static function esc_order( $order_query ) {
1314
-        if ( empty($order_query) ) {
1314
+        if ( empty( $order_query ) ) {
1315 1315
             return '';
1316 1316
         }
1317 1317
 
1318 1318
         // remove ORDER BY before santizing
1319
-        $order_query = strtolower($order_query);
1320
-        if ( strpos($order_query, 'order by') !== false ) {
1321
-            $order_query = str_replace('order by', '', $order_query);
1319
+        $order_query = strtolower( $order_query );
1320
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1321
+            $order_query = str_replace( 'order by', '', $order_query );
1322 1322
         }
1323 1323
 
1324
-        $order_query = explode(' ', trim($order_query));
1324
+        $order_query = explode( ' ', trim( $order_query ) );
1325 1325
 
1326 1326
         $order_fields = array(
1327 1327
             'id', 'form_key', 'name', 'description',
@@ -1329,18 +1329,18 @@  discard block
 block discarded – undo
1329 1329
             'default_template', 'status', 'created_at',
1330 1330
         );
1331 1331
 
1332
-        $order = trim(trim(reset($order_query), ','));
1333
-        if ( ! in_array($order, $order_fields) ) {
1332
+        $order = trim( trim( reset( $order_query ), ',' ) );
1333
+        if ( ! in_array( $order, $order_fields ) ) {
1334 1334
             return '';
1335 1335
         }
1336 1336
 
1337 1337
         $order_by = '';
1338
-        if ( count($order_query) > 1 ) {
1338
+        if ( count( $order_query ) > 1 ) {
1339 1339
 			$order_by = end( $order_query );
1340 1340
 			self::esc_order_by( $order_by );
1341 1341
         }
1342 1342
 
1343
-        return ' ORDER BY '. $order . ' '. $order_by;
1343
+        return ' ORDER BY ' . $order . ' ' . $order_by;
1344 1344
     }
1345 1345
 
1346 1346
 	/**
@@ -1357,24 +1357,24 @@  discard block
 block discarded – undo
1357 1357
      * @param string $limit
1358 1358
      */
1359 1359
 	public static function esc_limit( $limit ) {
1360
-        if ( empty($limit) ) {
1360
+        if ( empty( $limit ) ) {
1361 1361
             return '';
1362 1362
         }
1363 1363
 
1364
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1365
-        if ( is_numeric($limit) ) {
1366
-            return ' LIMIT '. $limit;
1364
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1365
+        if ( is_numeric( $limit ) ) {
1366
+            return ' LIMIT ' . $limit;
1367 1367
         }
1368 1368
 
1369
-        $limit = explode(',', trim($limit));
1369
+        $limit = explode( ',', trim( $limit ) );
1370 1370
         foreach ( $limit as $k => $l ) {
1371 1371
             if ( is_numeric( $l ) ) {
1372
-                $limit[ $k ] = $l;
1372
+                $limit[$k] = $l;
1373 1373
             }
1374 1374
         }
1375 1375
 
1376
-        $limit = implode(',', $limit);
1377
-        return ' LIMIT '. $limit;
1376
+        $limit = implode( ',', $limit );
1377
+        return ' LIMIT ' . $limit;
1378 1378
     }
1379 1379
 
1380 1380
     /**
@@ -1382,12 +1382,12 @@  discard block
 block discarded – undo
1382 1382
      * @since 2.0
1383 1383
      */
1384 1384
     public static function prepare_array_values( $array, $type = '%s' ) {
1385
-        $placeholders = array_fill(0, count($array), $type);
1386
-        return implode(', ', $placeholders);
1385
+        $placeholders = array_fill( 0, count( $array ), $type );
1386
+        return implode( ', ', $placeholders );
1387 1387
     }
1388 1388
 
1389 1389
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1390
-        if ( empty($where) ) {
1390
+        if ( empty( $where ) ) {
1391 1391
             return '';
1392 1392
         }
1393 1393
 
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
 
1434 1434
     public static function get_referer_info() {
1435 1435
         _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1436
-        return self::get_server_value('HTTP_REFERER');
1436
+        return self::get_server_value( 'HTTP_REFERER' );
1437 1437
     }
1438 1438
 
1439 1439
 	/**
@@ -1442,19 +1442,19 @@  discard block
 block discarded – undo
1442 1442
 	public static function json_to_array( $json_vars ) {
1443 1443
         $vars = array();
1444 1444
         foreach ( $json_vars as $jv ) {
1445
-            $jv_name = explode('[', $jv['name']);
1446
-            $last = count($jv_name) - 1;
1445
+            $jv_name = explode( '[', $jv['name'] );
1446
+            $last = count( $jv_name ) - 1;
1447 1447
             foreach ( $jv_name as $p => $n ) {
1448
-                $name = trim($n, ']');
1449
-                if ( ! isset($l1) ) {
1448
+                $name = trim( $n, ']' );
1449
+                if ( ! isset( $l1 ) ) {
1450 1450
                     $l1 = $name;
1451 1451
                 }
1452 1452
 
1453
-                if ( ! isset($l2) ) {
1453
+                if ( ! isset( $l2 ) ) {
1454 1454
                     $l2 = $name;
1455 1455
                 }
1456 1456
 
1457
-                if ( ! isset($l3) ) {
1457
+                if ( ! isset( $l3 ) ) {
1458 1458
                     $l3 = $name;
1459 1459
                 }
1460 1460
 
@@ -1468,24 +1468,24 @@  discard block
 block discarded – undo
1468 1468
 
1469 1469
                     case 1:
1470 1470
                         $l2 = $name;
1471
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1471
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1472 1472
                     break;
1473 1473
 
1474 1474
                     case 2:
1475 1475
                         $l3 = $name;
1476
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1476
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1477 1477
                     break;
1478 1478
 
1479 1479
                     case 3:
1480 1480
                         $l4 = $name;
1481
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1481
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1482 1482
                     break;
1483 1483
                 }
1484 1484
 
1485
-                unset($this_val, $n);
1485
+                unset( $this_val, $n );
1486 1486
             }
1487 1487
 
1488
-            unset($last, $jv);
1488
+            unset( $last, $jv );
1489 1489
         }
1490 1490
 
1491 1491
         return $vars;
@@ -1498,8 +1498,8 @@  discard block
 block discarded – undo
1498 1498
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1499 1499
         if ( $name == '' ) {
1500 1500
             $vars[] = $val;
1501
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1502
-            $vars[ $l1 ] = $val;
1501
+        } else if ( ! isset( $vars[$l1] ) ) {
1502
+            $vars[$l1] = $val;
1503 1503
         }
1504 1504
     }
1505 1505
 
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
             '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() ) ),
1515 1515
         );
1516 1516
 
1517
-        if ( ! isset( $tooltips[ $name ] ) ) {
1517
+        if ( ! isset( $tooltips[$name] ) ) {
1518 1518
             return;
1519 1519
         }
1520 1520
 
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
             echo ' class="frm_help"';
1525 1525
         }
1526 1526
 
1527
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1527
+        echo ' title="' . esc_attr( $tooltips[$name] );
1528 1528
 
1529 1529
         if ( 'open' != $class ) {
1530 1530
             echo '"';
@@ -1576,13 +1576,13 @@  discard block
 block discarded – undo
1576 1576
     }
1577 1577
 
1578 1578
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1579
-		if ( ! isset( $post_content[ $key ] ) ) {
1579
+		if ( ! isset( $post_content[$key] ) ) {
1580 1580
 			return;
1581 1581
 		}
1582 1582
 
1583 1583
 		if ( is_array( $val ) ) {
1584 1584
 			foreach ( $val as $k1 => $v1 ) {
1585
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1585
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1586 1586
 				unset( $k1, $v1 );
1587 1587
 			}
1588 1588
 		} else {
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
 			$val = stripslashes( $val );
1591 1591
 
1592 1592
 			// Add backslashes before double quotes and forward slashes only
1593
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1593
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1594 1594
 		}
1595 1595
 	}
1596 1596
 
@@ -1607,7 +1607,7 @@  discard block
 block discarded – undo
1607 1607
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1608 1608
 
1609 1609
 		if ( empty( $settings['ID'] ) ) {
1610
-			unset( $settings['ID']);
1610
+			unset( $settings['ID'] );
1611 1611
 		}
1612 1612
 
1613 1613
 		// delete all caches for this group
@@ -1641,17 +1641,17 @@  discard block
 block discarded – undo
1641 1641
 	}
1642 1642
 
1643 1643
 	public static function maybe_json_decode( $string ) {
1644
-        if ( is_array($string) ) {
1644
+        if ( is_array( $string ) ) {
1645 1645
             return $string;
1646 1646
         }
1647 1647
 
1648
-        $new_string = json_decode($string, true);
1649
-        if ( function_exists('json_last_error') ) {
1648
+        $new_string = json_decode( $string, true );
1649
+        if ( function_exists( 'json_last_error' ) ) {
1650 1650
 			// php 5.3+
1651 1651
             if ( json_last_error() == JSON_ERROR_NONE ) {
1652 1652
                 $string = $new_string;
1653 1653
             }
1654
-        } else if ( isset($new_string) ) {
1654
+        } else if ( isset( $new_string ) ) {
1655 1655
 			// php < 5.3 fallback
1656 1656
             $string = $new_string;
1657 1657
         }
@@ -1667,11 +1667,11 @@  discard block
 block discarded – undo
1667 1667
 	public static function maybe_highlight_menu( $post_type ) {
1668 1668
         global $post, $pagenow;
1669 1669
 
1670
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1670
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1671 1671
             return;
1672 1672
         }
1673 1673
 
1674
-        if ( is_object($post) && $post->post_type != $post_type ) {
1674
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1675 1675
             return;
1676 1676
         }
1677 1677
 
@@ -1769,11 +1769,11 @@  discard block
 block discarded – undo
1769 1769
         $frm_version = self::plugin_version();
1770 1770
 
1771 1771
         // check if Formidable meets minimum requirements
1772
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1772
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1773 1773
             return;
1774 1774
         }
1775 1775
 
1776
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1776
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1777 1777
 		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">' .
1778 1778
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1779 1779
         '</div></td></tr>';
@@ -1781,38 +1781,38 @@  discard block
 block discarded – undo
1781 1781
 
1782 1782
     public static function locales( $type = 'date' ) {
1783 1783
         $locales = array(
1784
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1785
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1786
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1784
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1785
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1786
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1787 1787
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1788
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1789
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1788
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1789
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1790 1790
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1791
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1792
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1791
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1792
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1793 1793
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1794
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1794
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1795 1795
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1796
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1796
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1797 1797
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1798
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1798
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1799 1799
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1800
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1801
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1802
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1803
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1804
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1800
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1801
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1802
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1803
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1804
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1805 1805
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1806
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1806
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1807 1807
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1808 1808
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1809
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1809
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1810 1810
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1811
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1811
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1812 1812
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1813
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1814
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1815
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1813
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1814
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1815
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1816 1816
         );
1817 1817
 
1818 1818
         if ( $type == 'captcha' ) {
@@ -1831,8 +1831,8 @@  discard block
 block discarded – undo
1831 1831
             );
1832 1832
         }
1833 1833
 
1834
-        $locales = array_diff_key($locales, array_flip($unset));
1835
-        $locales = apply_filters('frm_locales', $locales);
1834
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1835
+        $locales = apply_filters( 'frm_locales', $locales );
1836 1836
 
1837 1837
         return $locales;
1838 1838
     }
Please login to merge, or discard this patch.