Completed
Push — master ( 7b84d5...a9c2e2 )
by Jamie
06:53
created
classes/helpers/FrmAppHelper.php 1 patch
Spacing   +224 added lines, -224 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 );
@@ -1260,10 +1260,10 @@  discard block
 block discarded – undo
1260 1260
 		$time_strings = self::get_time_strings();
1261 1261
 
1262 1262
 		foreach ( $time_strings as $k => $v ) {
1263
-			if ( $diff[ $k ] ) {
1264
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1263
+			if ( $diff[$k] ) {
1264
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1265 1265
 			} else {
1266
-				unset( $time_strings[ $k ] );
1266
+				unset( $time_strings[$k] );
1267 1267
 			}
1268 1268
 		}
1269 1269
 
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
      */
1302 1302
 	public static function esc_like( $term ) {
1303 1303
         global $wpdb;
1304
-        if ( method_exists($wpdb, 'esc_like') ) {
1304
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1305 1305
 			// WP 4.0
1306 1306
             $term = $wpdb->esc_like( $term );
1307 1307
         } else {
@@ -1315,17 +1315,17 @@  discard block
 block discarded – undo
1315 1315
      * @param string $order_query
1316 1316
      */
1317 1317
 	public static function esc_order( $order_query ) {
1318
-        if ( empty($order_query) ) {
1318
+        if ( empty( $order_query ) ) {
1319 1319
             return '';
1320 1320
         }
1321 1321
 
1322 1322
         // remove ORDER BY before santizing
1323
-        $order_query = strtolower($order_query);
1324
-        if ( strpos($order_query, 'order by') !== false ) {
1325
-            $order_query = str_replace('order by', '', $order_query);
1323
+        $order_query = strtolower( $order_query );
1324
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1325
+            $order_query = str_replace( 'order by', '', $order_query );
1326 1326
         }
1327 1327
 
1328
-        $order_query = explode(' ', trim($order_query));
1328
+        $order_query = explode( ' ', trim( $order_query ) );
1329 1329
 
1330 1330
         $order_fields = array(
1331 1331
             'id', 'form_key', 'name', 'description',
@@ -1333,18 +1333,18 @@  discard block
 block discarded – undo
1333 1333
             'default_template', 'status', 'created_at',
1334 1334
         );
1335 1335
 
1336
-        $order = trim(trim(reset($order_query), ','));
1337
-        if ( ! in_array($order, $order_fields) ) {
1336
+        $order = trim( trim( reset( $order_query ), ',' ) );
1337
+        if ( ! in_array( $order, $order_fields ) ) {
1338 1338
             return '';
1339 1339
         }
1340 1340
 
1341 1341
         $order_by = '';
1342
-        if ( count($order_query) > 1 ) {
1342
+        if ( count( $order_query ) > 1 ) {
1343 1343
 			$order_by = end( $order_query );
1344 1344
 			self::esc_order_by( $order_by );
1345 1345
         }
1346 1346
 
1347
-        return ' ORDER BY '. $order . ' '. $order_by;
1347
+        return ' ORDER BY ' . $order . ' ' . $order_by;
1348 1348
     }
1349 1349
 
1350 1350
 	/**
@@ -1361,24 +1361,24 @@  discard block
 block discarded – undo
1361 1361
      * @param string $limit
1362 1362
      */
1363 1363
 	public static function esc_limit( $limit ) {
1364
-        if ( empty($limit) ) {
1364
+        if ( empty( $limit ) ) {
1365 1365
             return '';
1366 1366
         }
1367 1367
 
1368
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1369
-        if ( is_numeric($limit) ) {
1370
-            return ' LIMIT '. $limit;
1368
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1369
+        if ( is_numeric( $limit ) ) {
1370
+            return ' LIMIT ' . $limit;
1371 1371
         }
1372 1372
 
1373
-        $limit = explode(',', trim($limit));
1373
+        $limit = explode( ',', trim( $limit ) );
1374 1374
         foreach ( $limit as $k => $l ) {
1375 1375
             if ( is_numeric( $l ) ) {
1376
-                $limit[ $k ] = $l;
1376
+                $limit[$k] = $l;
1377 1377
             }
1378 1378
         }
1379 1379
 
1380
-        $limit = implode(',', $limit);
1381
-        return ' LIMIT '. $limit;
1380
+        $limit = implode( ',', $limit );
1381
+        return ' LIMIT ' . $limit;
1382 1382
     }
1383 1383
 
1384 1384
     /**
@@ -1386,12 +1386,12 @@  discard block
 block discarded – undo
1386 1386
      * @since 2.0
1387 1387
      */
1388 1388
     public static function prepare_array_values( $array, $type = '%s' ) {
1389
-        $placeholders = array_fill(0, count($array), $type);
1390
-        return implode(', ', $placeholders);
1389
+        $placeholders = array_fill( 0, count( $array ), $type );
1390
+        return implode( ', ', $placeholders );
1391 1391
     }
1392 1392
 
1393 1393
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1394
-        if ( empty($where) ) {
1394
+        if ( empty( $where ) ) {
1395 1395
             return '';
1396 1396
         }
1397 1397
 
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 
1438 1438
     public static function get_referer_info() {
1439 1439
         _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1440
-        return self::get_server_value('HTTP_REFERER');
1440
+        return self::get_server_value( 'HTTP_REFERER' );
1441 1441
     }
1442 1442
 
1443 1443
 	/**
@@ -1446,19 +1446,19 @@  discard block
 block discarded – undo
1446 1446
 	public static function json_to_array( $json_vars ) {
1447 1447
         $vars = array();
1448 1448
         foreach ( $json_vars as $jv ) {
1449
-            $jv_name = explode('[', $jv['name']);
1450
-            $last = count($jv_name) - 1;
1449
+            $jv_name = explode( '[', $jv['name'] );
1450
+            $last = count( $jv_name ) - 1;
1451 1451
             foreach ( $jv_name as $p => $n ) {
1452
-                $name = trim($n, ']');
1453
-                if ( ! isset($l1) ) {
1452
+                $name = trim( $n, ']' );
1453
+                if ( ! isset( $l1 ) ) {
1454 1454
                     $l1 = $name;
1455 1455
                 }
1456 1456
 
1457
-                if ( ! isset($l2) ) {
1457
+                if ( ! isset( $l2 ) ) {
1458 1458
                     $l2 = $name;
1459 1459
                 }
1460 1460
 
1461
-                if ( ! isset($l3) ) {
1461
+                if ( ! isset( $l3 ) ) {
1462 1462
                     $l3 = $name;
1463 1463
                 }
1464 1464
 
@@ -1472,24 +1472,24 @@  discard block
 block discarded – undo
1472 1472
 
1473 1473
                     case 1:
1474 1474
                         $l2 = $name;
1475
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1475
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1476 1476
                     break;
1477 1477
 
1478 1478
                     case 2:
1479 1479
                         $l3 = $name;
1480
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1480
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1481 1481
                     break;
1482 1482
 
1483 1483
                     case 3:
1484 1484
                         $l4 = $name;
1485
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1485
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1486 1486
                     break;
1487 1487
                 }
1488 1488
 
1489
-                unset($this_val, $n);
1489
+                unset( $this_val, $n );
1490 1490
             }
1491 1491
 
1492
-            unset($last, $jv);
1492
+            unset( $last, $jv );
1493 1493
         }
1494 1494
 
1495 1495
         return $vars;
@@ -1502,8 +1502,8 @@  discard block
 block discarded – undo
1502 1502
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1503 1503
         if ( $name == '' ) {
1504 1504
             $vars[] = $val;
1505
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1506
-            $vars[ $l1 ] = $val;
1505
+        } else if ( ! isset( $vars[$l1] ) ) {
1506
+            $vars[$l1] = $val;
1507 1507
         }
1508 1508
     }
1509 1509
 
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
             '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() ) ),
1519 1519
         );
1520 1520
 
1521
-        if ( ! isset( $tooltips[ $name ] ) ) {
1521
+        if ( ! isset( $tooltips[$name] ) ) {
1522 1522
             return;
1523 1523
         }
1524 1524
 
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
             echo ' class="frm_help"';
1529 1529
         }
1530 1530
 
1531
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1531
+        echo ' title="' . esc_attr( $tooltips[$name] );
1532 1532
 
1533 1533
         if ( 'open' != $class ) {
1534 1534
             echo '"';
@@ -1580,13 +1580,13 @@  discard block
 block discarded – undo
1580 1580
     }
1581 1581
 
1582 1582
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1583
-		if ( ! isset( $post_content[ $key ] ) ) {
1583
+		if ( ! isset( $post_content[$key] ) ) {
1584 1584
 			return;
1585 1585
 		}
1586 1586
 
1587 1587
 		if ( is_array( $val ) ) {
1588 1588
 			foreach ( $val as $k1 => $v1 ) {
1589
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1589
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1590 1590
 				unset( $k1, $v1 );
1591 1591
 			}
1592 1592
 		} else {
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
 			$val = stripslashes( $val );
1595 1595
 
1596 1596
 			// Add backslashes before double quotes and forward slashes only
1597
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1597
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1598 1598
 		}
1599 1599
 	}
1600 1600
 
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1612 1612
 
1613 1613
 		if ( empty( $settings['ID'] ) ) {
1614
-			unset( $settings['ID']);
1614
+			unset( $settings['ID'] );
1615 1615
 		}
1616 1616
 
1617 1617
 		// delete all caches for this group
@@ -1645,17 +1645,17 @@  discard block
 block discarded – undo
1645 1645
 	}
1646 1646
 
1647 1647
 	public static function maybe_json_decode( $string ) {
1648
-        if ( is_array($string) ) {
1648
+        if ( is_array( $string ) ) {
1649 1649
             return $string;
1650 1650
         }
1651 1651
 
1652
-        $new_string = json_decode($string, true);
1653
-        if ( function_exists('json_last_error') ) {
1652
+        $new_string = json_decode( $string, true );
1653
+        if ( function_exists( 'json_last_error' ) ) {
1654 1654
 			// php 5.3+
1655 1655
             if ( json_last_error() == JSON_ERROR_NONE ) {
1656 1656
                 $string = $new_string;
1657 1657
             }
1658
-        } else if ( isset($new_string) ) {
1658
+        } else if ( isset( $new_string ) ) {
1659 1659
 			// php < 5.3 fallback
1660 1660
             $string = $new_string;
1661 1661
         }
@@ -1671,11 +1671,11 @@  discard block
 block discarded – undo
1671 1671
 	public static function maybe_highlight_menu( $post_type ) {
1672 1672
         global $post, $pagenow;
1673 1673
 
1674
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1674
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1675 1675
             return;
1676 1676
         }
1677 1677
 
1678
-        if ( is_object($post) && $post->post_type != $post_type ) {
1678
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1679 1679
             return;
1680 1680
         }
1681 1681
 
@@ -1773,11 +1773,11 @@  discard block
 block discarded – undo
1773 1773
         $frm_version = self::plugin_version();
1774 1774
 
1775 1775
         // check if Formidable meets minimum requirements
1776
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1776
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1777 1777
             return;
1778 1778
         }
1779 1779
 
1780
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1780
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1781 1781
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1782 1782
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1783 1783
         '</div></td></tr>';
@@ -1785,38 +1785,38 @@  discard block
 block discarded – undo
1785 1785
 
1786 1786
     public static function locales( $type = 'date' ) {
1787 1787
         $locales = array(
1788
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1789
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1790
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1788
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1789
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1790
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1791 1791
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1792
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1793
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1792
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1793
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1794 1794
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1795
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1796
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1795
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1796
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1797 1797
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1798
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1798
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1799 1799
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1800
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1800
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1801 1801
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1802
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1802
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1803 1803
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1804
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1805
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1806
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1807
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1808
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1804
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1805
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1806
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1807
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1808
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1809 1809
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1810
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1810
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1811 1811
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1812 1812
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1813
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1813
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1814 1814
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1815
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1815
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1816 1816
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1817
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1818
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1819
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1817
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1818
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1819
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1820 1820
         );
1821 1821
 
1822 1822
         if ( $type == 'captcha' ) {
@@ -1835,8 +1835,8 @@  discard block
 block discarded – undo
1835 1835
             );
1836 1836
         }
1837 1837
 
1838
-        $locales = array_diff_key($locales, array_flip($unset));
1839
-        $locales = apply_filters('frm_locales', $locales);
1838
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1839
+        $locales = apply_filters( 'frm_locales', $locales );
1840 1840
 
1841 1841
         return $locales;
1842 1842
     }
Please login to merge, or discard this patch.