Completed
Push — master ( f08bb3...dda2f6 )
by Jamie
03:30
created
classes/helpers/FrmAppHelper.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -746,6 +746,9 @@  discard block
 block discarded – undo
746 746
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
747 747
     }
748 748
 
749
+	/**
750
+	 * @param string $function
751
+	 */
749 752
 	public static function recursive_function_map( $value, $function ) {
750 753
 		if ( is_array( $value ) ) {
751 754
 			$original_function = $function;
@@ -1173,6 +1176,9 @@  discard block
 block discarded – undo
1173 1176
         return $sub . (($len < $original_len) ? $continue : '');
1174 1177
     }
1175 1178
 
1179
+	/**
1180
+	 * @param string[] $function_names
1181
+	 */
1176 1182
 	public static function mb_function( $function_names, $args ) {
1177 1183
 		$mb_function_name = $function_names[0];
1178 1184
 		$function_name = $function_names[1];
@@ -1206,6 +1212,9 @@  discard block
 block discarded – undo
1206 1212
         return $formatted;
1207 1213
     }
1208 1214
 
1215
+	/**
1216
+	 * @param string $time_format
1217
+	 */
1209 1218
 	private static function add_time_to_date( $time_format, $date ) {
1210 1219
 		if ( empty( $time_format ) ) {
1211 1220
 			$time_format = get_option('time_format');
Please login to merge, or discard this patch.
Spacing   +226 added lines, -226 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,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string
55 55
      */
56 56
     public static function site_name() {
57
-        return get_option('blogname');
57
+        return get_option( 'blogname' );
58 58
     }
59 59
 
60 60
     /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public static function get_settings() {
69 69
         global $frm_settings;
70
-        if ( empty($frm_settings) ) {
70
+        if ( empty( $frm_settings ) ) {
71 71
             $frm_settings = new FrmSettings();
72 72
         }
73 73
         return $frm_settings;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
     public static function pro_is_installed() {
86
-        return apply_filters('frm_pro_installed', false);
86
+        return apply_filters( 'frm_pro_installed', false );
87 87
     }
88 88
 
89 89
     /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      * @return boolean
128 128
      */
129 129
     public static function doing_ajax() {
130
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
130
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
131 131
     }
132 132
 
133 133
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      * @return boolean
148 148
      */
149 149
     public static function is_admin() {
150
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
150
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
151 151
     }
152 152
 
153 153
     /**
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      * @return string
174 174
      */
175 175
 	public static function get_server_value( $value ) {
176
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
176
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
177 177
     }
178 178
 
179 179
     /**
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
189 189
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
190 190
         ) as $key ) {
191
-            if ( ! isset( $_SERVER[ $key ] ) ) {
191
+            if ( ! isset( $_SERVER[$key] ) ) {
192 192
                 continue;
193 193
             }
194 194
 
195
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
196
-                $ip = trim($ip); // just to be safe
195
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
196
+                $ip = trim( $ip ); // just to be safe
197 197
 
198
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
198
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
199 199
                     return $ip;
200 200
                 }
201 201
             }
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
     }
206 206
 
207 207
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
208
-        if ( strpos($param, '[') ) {
209
-            $params = explode('[', $param);
208
+        if ( strpos( $param, '[' ) ) {
209
+            $params = explode( '[', $param );
210 210
             $param = $params[0];
211 211
         }
212 212
 
213 213
 		if ( $src == 'get' ) {
214
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
215
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
216
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
214
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
215
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
216
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
217 217
             }
218 218
 			self::sanitize_value( $sanitize, $value );
219 219
 		} else {
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 
223 223
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
224 224
             foreach ( $params as $k => $p ) {
225
-                if ( ! $k || ! is_array($value) ) {
225
+                if ( ! $k || ! is_array( $value ) ) {
226 226
                     continue;
227 227
                 }
228 228
 
229
-                $p = trim($p, ']');
230
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
229
+                $p = trim( $p, ']' );
230
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
231 231
             }
232 232
         }
233 233
 
@@ -269,16 +269,16 @@  discard block
 block discarded – undo
269 269
 
270 270
 		$value = $args['default'];
271 271
 		if ( $args['type'] == 'get' ) {
272
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
273
-				$value = $_GET[ $args['param'] ];
272
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
273
+				$value = $_GET[$args['param']];
274 274
 			}
275 275
 		} else if ( $args['type'] == 'post' ) {
276
-			if ( isset( $_POST[ $args['param'] ] ) ) {
277
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
276
+			if ( isset( $_POST[$args['param']] ) ) {
277
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
278 278
 			}
279 279
 		} else {
280
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
281
-				$value = $_REQUEST[ $args['param'] ];
280
+			if ( isset( $_REQUEST[$args['param']] ) ) {
281
+				$value = $_REQUEST[$args['param']];
282 282
 			}
283 283
 		}
284 284
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
     public static function sanitize_request( $sanitize_method, &$values ) {
315 315
         $temp_values = $values;
316 316
         foreach ( $temp_values as $k => $val ) {
317
-            if ( isset( $sanitize_method[ $k ] ) ) {
318
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
317
+            if ( isset( $sanitize_method[$k] ) ) {
318
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
319 319
             }
320 320
         }
321 321
     }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	public static function sanitize_array( &$values ) {
324 324
 		$temp_values = $values;
325 325
 		foreach ( $temp_values as $k => $val ) {
326
-			$values[ $k ] = wp_kses_post( $val );
326
+			$values[$k] = wp_kses_post( $val );
327 327
 		}
328 328
 	}
329 329
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 
344 344
 		$allowed_html = array();
345 345
 		foreach ( $allowed as $a ) {
346
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
346
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
347 347
 		}
348 348
 
349 349
 		return wp_kses( $value, $allowed_html );
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      * @since 2.0
355 355
      */
356 356
     public static function remove_get_action() {
357
-        if ( ! isset($_GET) ) {
357
+        if ( ! isset( $_GET ) ) {
358 358
             return;
359 359
         }
360 360
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
         }
377 377
 
378 378
         global $wp_query;
379
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
380
-            $value = $wp_query->query_vars[ $param ];
379
+        if ( isset( $wp_query->query_vars[$param] ) ) {
380
+            $value = $wp_query->query_vars[$param];
381 381
         }
382 382
 
383 383
         return $value;
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
      */
389 389
     public static function trigger_hook_load( $type, $object = null ) {
390 390
         // only load the form hooks once
391
-        $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
391
+        $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
392 392
         if ( ! $hooks_loaded ) {
393
-            do_action('frm_load_'. $type .'_hooks');
393
+            do_action( 'frm_load_' . $type . '_hooks' );
394 394
         }
395 395
     }
396 396
 
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
      * @return mixed $results The cache or query results
407 407
      */
408 408
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
409
-        $results = wp_cache_get($cache_key, $group);
410
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
409
+        $results = wp_cache_get( $cache_key, $group );
410
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
411 411
             return $results;
412 412
         }
413 413
 
414 414
         if ( 'get_posts' == $type ) {
415
-            $results = get_posts($query);
415
+            $results = get_posts( $query );
416 416
         } else {
417 417
             global $wpdb;
418
-            $results = $wpdb->{$type}($query);
418
+            $results = $wpdb->{$type}( $query );
419 419
         }
420 420
 
421 421
 		if ( ! self::prevent_caching() ) {
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
         }
440 440
 
441 441
         // then check the transient
442
-        $results = get_transient($cache_key);
442
+        $results = get_transient( $cache_key );
443 443
         if ( $results ) {
444
-            wp_cache_set($cache_key, $results);
444
+            wp_cache_set( $cache_key, $results );
445 445
         }
446 446
 
447 447
         return $results;
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
      * @param string $cache_key
453 453
      */
454 454
 	public static function delete_cache_and_transient( $cache_key ) {
455
-        delete_transient($cache_key);
456
-        wp_cache_delete($cache_key);
455
+        delete_transient( $cache_key );
456
+        wp_cache_delete( $cache_key );
457 457
     }
458 458
 
459 459
     /**
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 	public static function cache_delete_group( $group ) {
468 468
     	global $wp_object_cache;
469 469
 
470
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
471
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
472
-                wp_cache_delete($k, $group);
470
+        if ( isset( $wp_object_cache->cache[$group] ) ) {
471
+            foreach ( $wp_object_cache->cache[$group] as $k => $v ) {
472
+                wp_cache_delete( $k, $group );
473 473
             }
474 474
             return true;
475 475
         }
@@ -500,29 +500,29 @@  discard block
 block discarded – undo
500 500
 	public static function load_scripts( $scripts ) {
501 501
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
502 502
         foreach ( (array) $scripts as $s ) {
503
-            wp_enqueue_script($s);
503
+            wp_enqueue_script( $s );
504 504
         }
505 505
     }
506 506
 
507 507
 	public static function load_styles( $styles ) {
508 508
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
509 509
         foreach ( (array) $styles as $s ) {
510
-            wp_enqueue_style($s);
510
+            wp_enqueue_style( $s );
511 511
         }
512 512
     }
513 513
 
514 514
     public static function get_pages() {
515
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
515
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
516 516
     }
517 517
 
518 518
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
519 519
         $pages = self::get_pages();
520 520
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
521 521
     ?>
522
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
522
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
523 523
             <option value=""> </option>
524 524
             <?php foreach ( $pages as $page ) { ?>
525
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
525
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
526 526
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
527 527
 				</option>
528 528
             <?php } ?>
@@ -531,26 +531,26 @@  discard block
 block discarded – undo
531 531
     }
532 532
 
533 533
 	public static function post_edit_link( $post_id ) {
534
-        $post = get_post($post_id);
534
+        $post = get_post( $post_id );
535 535
         if ( $post ) {
536
-            return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
536
+            return '<a href="' . esc_url( admin_url( 'post.php' ) . '?post=' . $post_id . '&action=edit' ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
537 537
         }
538 538
         return '';
539 539
     }
540 540
 
541 541
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
542 542
     ?>
543
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
543
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
544 544
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
545 545
             ?> class="frm_multiselect">
546
-            <?php self::roles_options($capability); ?>
546
+            <?php self::roles_options( $capability ); ?>
547 547
         </select>
548 548
     <?php
549 549
     }
550 550
 
551 551
 	public static function roles_options( $capability ) {
552 552
         global $frm_vars;
553
-        if ( isset($frm_vars['editable_roles']) ) {
553
+        if ( isset( $frm_vars['editable_roles'] ) ) {
554 554
             $editable_roles = $frm_vars['editable_roles'];
555 555
         } else {
556 556
             $editable_roles = get_editable_roles();
@@ -558,10 +558,10 @@  discard block
 block discarded – undo
558 558
         }
559 559
 
560 560
         foreach ( $editable_roles as $role => $details ) {
561
-            $name = translate_user_role($details['name'] ); ?>
562
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
561
+            $name = translate_user_role( $details['name'] ); ?>
562
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
563 563
 <?php
564
-            unset($role, $details);
564
+            unset( $role, $details );
565 565
         }
566 566
     }
567 567
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
     public static function maybe_add_permissions() {
618 618
 		self::force_capability( 'frm_view_entries' );
619 619
 
620
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
620
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
621 621
             return;
622 622
         }
623 623
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
         $frm_roles = self::frm_capabilities();
627 627
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
628 628
 			$user->add_cap( $frm_role );
629
-            unset($frm_role, $frm_role_description);
629
+            unset( $frm_role, $frm_role_description );
630 630
         }
631 631
     }
632 632
 
@@ -651,12 +651,12 @@  discard block
 block discarded – undo
651 651
      * @param string $permission
652 652
      */
653 653
 	public static function permission_check( $permission, $show_message = 'show' ) {
654
-        $permission_error = self::permission_nonce_error($permission);
654
+        $permission_error = self::permission_nonce_error( $permission );
655 655
         if ( $permission_error !== false ) {
656 656
             if ( 'hide' == $show_message ) {
657 657
                 $permission_error = '';
658 658
             }
659
-            wp_die($permission_error);
659
+            wp_die( $permission_error );
660 660
         }
661 661
     }
662 662
 
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 		}
674 674
 
675 675
 		$error = false;
676
-        if ( empty($nonce_name) ) {
676
+        if ( empty( $nonce_name ) ) {
677 677
             return $error;
678 678
         }
679 679
 
680
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
680
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
681 681
             $frm_settings = self::get_settings();
682 682
             $error = $frm_settings->admin_permission;
683 683
         }
@@ -693,9 +693,9 @@  discard block
 block discarded – undo
693 693
 
694 694
 	public static function check_selected( $values, $current ) {
695 695
         $values = self::recursive_function_map( $values, 'trim' );
696
-        $current = trim($current);
696
+        $current = trim( $current );
697 697
 
698
-        return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
698
+        return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
699 699
     }
700 700
 
701 701
     /**
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			} else {
757 757
 				foreach ( $value as $k => $v ) {
758 758
 					if ( ! is_array( $v ) ) {
759
-						$value[ $k ] = call_user_func( $original_function, $v );
759
+						$value[$k] = call_user_func( $original_function, $v );
760 760
 					}
761 761
 				}
762 762
 			}
@@ -777,11 +777,11 @@  discard block
 block discarded – undo
777 777
 	public static function array_flatten( $array, $keys = 'keep' ) {
778 778
         $return = array();
779 779
         foreach ( $array as $key => $value ) {
780
-            if ( is_array($value) ) {
780
+            if ( is_array( $value ) ) {
781 781
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
782 782
             } else {
783 783
 				if ( $keys == 'keep' ) {
784
-					$return[ $key ] = $value;
784
+					$return[$key] = $value;
785 785
 				} else {
786 786
 					$return[] = $value;
787 787
 				}
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     }
792 792
 
793 793
     public static function esc_textarea( $text ) {
794
-        $safe_text = str_replace('&quot;', '"', $text);
794
+        $safe_text = str_replace( '&quot;', '"', $text );
795 795
         $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
796 796
     	return apply_filters( 'esc_textarea', $safe_text, $text );
797 797
     }
@@ -801,8 +801,8 @@  discard block
 block discarded – undo
801 801
      * @since 2.0
802 802
      */
803 803
 	public static function use_wpautop( $content ) {
804
-        if ( apply_filters('frm_use_wpautop', true) ) {
805
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
804
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
805
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
806 806
         }
807 807
         return $content;
808 808
     }
@@ -820,8 +820,8 @@  discard block
 block discarded – undo
820 820
      * @return string The base Google APIS url for the current version of jQuery UI
821 821
      */
822 822
     public static function jquery_ui_base_url() {
823
-        $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
824
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
823
+        $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
824
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
825 825
         return $url;
826 826
     }
827 827
 
@@ -836,11 +836,11 @@  discard block
 block discarded – undo
836 836
 
837 837
         $ver = 0;
838 838
 
839
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
839
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
840 840
             return $ver;
841 841
         }
842 842
 
843
-        $query = $wp_scripts->registered[ $handle ];
843
+        $query = $wp_scripts->registered[$handle];
844 844
     	if ( is_object( $query ) ) {
845 845
     	    $ver = $query->ver;
846 846
     	}
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
     }
854 854
 
855 855
 	public static function get_user_id_param( $user_id ) {
856
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
856
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
857 857
             return $user_id;
858 858
         }
859 859
 
@@ -861,29 +861,29 @@  discard block
 block discarded – undo
861 861
             $user_ID = get_current_user_id();
862 862
             $user_id = $user_ID;
863 863
 		} else {
864
-            if ( is_email($user_id) ) {
865
-                $user = get_user_by('email', $user_id);
864
+            if ( is_email( $user_id ) ) {
865
+                $user = get_user_by( 'email', $user_id );
866 866
             } else {
867
-                $user = get_user_by('login', $user_id);
867
+                $user = get_user_by( 'login', $user_id );
868 868
             }
869 869
 
870 870
             if ( $user ) {
871 871
                 $user_id = $user->ID;
872 872
             }
873
-            unset($user);
873
+            unset( $user );
874 874
         }
875 875
 
876 876
         return $user_id;
877 877
     }
878 878
 
879 879
 	public static function get_file_contents( $filename, $atts = array() ) {
880
-        if ( ! is_file($filename) ) {
880
+        if ( ! is_file( $filename ) ) {
881 881
             return false;
882 882
         }
883 883
 
884
-        extract($atts);
884
+        extract( $atts );
885 885
         ob_start();
886
-        include($filename);
886
+        include( $filename );
887 887
         $contents = ob_get_contents();
888 888
         ob_end_clean();
889 889
         return $contents;
@@ -899,28 +899,28 @@  discard block
 block discarded – undo
899 899
         $key = '';
900 900
 
901 901
         if ( ! empty( $name ) ) {
902
-            $key = sanitize_key($name);
902
+            $key = sanitize_key( $name );
903 903
         }
904 904
 
905 905
 		if ( empty( $key ) ) {
906
-            $max_slug_value = pow(36, $num_chars);
906
+            $max_slug_value = pow( 36, $num_chars );
907 907
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
908
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
908
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
909 909
         }
910 910
 
911
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
912
-            $key = $key .'a';
911
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
912
+            $key = $key . 'a';
913 913
         }
914 914
 
915 915
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
916 916
 
917
-        if ( $key_check || is_numeric($key_check) ) {
917
+        if ( $key_check || is_numeric( $key_check ) ) {
918 918
             $suffix = 2;
919 919
 			do {
920 920
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
921 921
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
922
-				$suffix++;
923
-			} while ($key_check || is_numeric($key_check));
922
+				$suffix ++;
923
+			} while ( $key_check || is_numeric( $key_check ) );
924 924
 			$key = $alt_post_name;
925 925
         }
926 926
         return $key;
@@ -938,32 +938,32 @@  discard block
 block discarded – undo
938 938
 
939 939
         global $frm_vars;
940 940
 
941
-        if ( empty($post_values) ) {
942
-            $post_values = stripslashes_deep($_POST);
941
+        if ( empty( $post_values ) ) {
942
+            $post_values = stripslashes_deep( $_POST );
943 943
         }
944 944
 
945 945
 		$values = array( 'id' => $record->id, 'fields' => array() );
946 946
 
947 947
 		foreach ( array( 'name', 'description' ) as $var ) {
948
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
949
-            $values[ $var ] = self::get_param( $var, $default_val );
950
-            unset($var, $default_val);
948
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
949
+            $values[$var] = self::get_param( $var, $default_val );
950
+            unset( $var, $default_val );
951 951
         }
952 952
 
953
-        $values['description'] = self::use_wpautop($values['description']);
953
+        $values['description'] = self::use_wpautop( $values['description'] );
954 954
         $frm_settings = self::get_settings();
955
-        $is_form_builder = self::is_admin_page('formidable' );
955
+        $is_form_builder = self::is_admin_page( 'formidable' );
956 956
 
957 957
         foreach ( (array) $fields as $field ) {
958 958
             // Make sure to filter default values (for placeholder text), but not on the form builder page
959 959
             if ( ! $is_form_builder ) {
960
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
960
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
961 961
             }
962 962
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
963
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
963
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
964 964
         }
965 965
 
966
-        self::fill_form_opts($record, $table, $post_values, $values);
966
+        self::fill_form_opts( $record, $table, $post_values, $values );
967 967
 
968 968
         if ( $table == 'entries' ) {
969 969
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
         if ( $args['default'] ) {
981 981
             $meta_value = $field->default_value;
982 982
         } else {
983
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
984
-                if ( ! isset($field->field_options['custom_field']) ) {
983
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
984
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
985 985
                     $field->field_options['custom_field'] = '';
986 986
                 }
987 987
 				$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 ) );
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
             }
991 991
         }
992 992
 
993
-        $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
994
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
993
+        $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
994
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
995 995
 
996 996
         $field_array = array(
997 997
             'id'            => $field->id,
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
             'default_value' => $field->default_value,
1000 1000
             'name'          => $field->name,
1001 1001
             'description'   => $field->description,
1002
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1002
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1003 1003
             'options'       => $field->options,
1004 1004
             'required'      => $field->required,
1005 1005
             'field_key'     => $field->field_key,
@@ -1009,38 +1009,38 @@  discard block
 block discarded – undo
1009 1009
         );
1010 1010
 
1011 1011
         $args['field_type'] = $field_type;
1012
-        self::fill_field_opts($field, $field_array, $args);
1012
+        self::fill_field_opts( $field, $field_array, $args );
1013 1013
 
1014
-        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1014
+        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] );
1015 1015
 
1016
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1016
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1017 1017
             $field_array['unique_msg'] = '';
1018 1018
         }
1019 1019
 
1020 1020
         $field_array = array_merge( $field->field_options, $field_array );
1021 1021
 
1022
-        $values['fields'][ $field->id ] = $field_array;
1022
+        $values['fields'][$field->id] = $field_array;
1023 1023
     }
1024 1024
 
1025 1025
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1026 1026
         $post_values = $args['post_values'];
1027
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1027
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1028 1028
 
1029 1029
         foreach ( $opt_defaults as $opt => $default_opt ) {
1030
-            $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 );
1031
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1032
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1033
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1030
+            $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 );
1031
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1032
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1033
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1034 1034
                 if ( $args['field_type'] == 'captcha' ) {
1035
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1035
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1036 1036
                 } else {
1037
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1037
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1038 1038
                 }
1039 1039
             }
1040 1040
         }
1041 1041
 
1042 1042
         if ( $field_array['custom_html'] == '' ) {
1043
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1043
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1044 1044
         }
1045 1045
     }
1046 1046
 
@@ -1059,18 +1059,18 @@  discard block
 block discarded – undo
1059 1059
             return;
1060 1060
         }
1061 1061
 
1062
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1062
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1063 1063
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1064 1064
 
1065
-        if ( ! is_array($form->options) ) {
1065
+        if ( ! is_array( $form->options ) ) {
1066 1066
             return;
1067 1067
         }
1068 1068
 
1069 1069
         foreach ( $form->options as $opt => $value ) {
1070
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1070
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1071 1071
         }
1072 1072
 
1073
-        self::fill_form_defaults($post_values, $values);
1073
+        self::fill_form_defaults( $post_values, $values );
1074 1074
     }
1075 1075
 
1076 1076
     /**
@@ -1080,23 +1080,23 @@  discard block
 block discarded – undo
1080 1080
         $form_defaults = FrmFormsHelper::get_default_opts();
1081 1081
 
1082 1082
         foreach ( $form_defaults as $opt => $default ) {
1083
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1084
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1083
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1084
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1085 1085
             }
1086 1086
 
1087
-            unset($opt, $defaut);
1087
+            unset( $opt, $defaut );
1088 1088
         }
1089 1089
 
1090
-        if ( ! isset($values['custom_style']) ) {
1090
+        if ( ! isset( $values['custom_style'] ) ) {
1091 1091
             $frm_settings = self::get_settings();
1092 1092
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1093 1093
         }
1094 1094
 
1095 1095
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1096
-            if ( ! isset( $values[ $h .'_html' ] ) ) {
1097
-                $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1096
+            if ( ! isset( $values[$h . '_html'] ) ) {
1097
+                $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1098 1098
             }
1099
-            unset($h);
1099
+            unset( $h );
1100 1100
         }
1101 1101
     }
1102 1102
 
@@ -1112,9 +1112,9 @@  discard block
 block discarded – undo
1112 1112
         }
1113 1113
     ?>
1114 1114
 <li>
1115
-    <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>
1116
-    <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>
1117
-    <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>
1115
+    <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>
1116
+    <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>
1117
+    <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>
1118 1118
 </li>
1119 1119
     <?php
1120 1120
     }
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
             return '';
1143 1143
         } else if ( $length <= 10 ) {
1144 1144
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1145
-            return $sub . (($length < $original_len) ? $continue : '');
1145
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1146 1146
         }
1147 1147
 
1148 1148
         $sub = '';
@@ -1151,23 +1151,23 @@  discard block
 block discarded – undo
1151 1151
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1152 1152
 
1153 1153
 		foreach ( $words as $word ) {
1154
-            $part = (($sub != '') ? ' ' : '') . $word;
1154
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1155 1155
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1156
-            if ( $total_len > $length && str_word_count($sub) ) {
1156
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1157 1157
                 break;
1158 1158
             }
1159 1159
 
1160 1160
             $sub .= $part;
1161 1161
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1162 1162
 
1163
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1163
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1164 1164
                 break;
1165 1165
             }
1166 1166
 
1167
-            unset($total_len, $word);
1167
+            unset( $total_len, $word );
1168 1168
         }
1169 1169
 
1170
-        return $sub . (($len < $original_len) ? $continue : '');
1170
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1171 1171
     }
1172 1172
 
1173 1173
 	public static function mb_function( $function_names, $args ) {
@@ -1180,17 +1180,17 @@  discard block
 block discarded – undo
1180 1180
 	}
1181 1181
 
1182 1182
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1183
-        if ( empty($date) ) {
1183
+        if ( empty( $date ) ) {
1184 1184
             return $date;
1185 1185
         }
1186 1186
 
1187
-        if ( empty($date_format) ) {
1188
-            $date_format = get_option('date_format');
1187
+        if ( empty( $date_format ) ) {
1188
+            $date_format = get_option( 'date_format' );
1189 1189
         }
1190 1190
 
1191
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1191
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1192 1192
             $frmpro_settings = new FrmProSettings();
1193
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1193
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1194 1194
         }
1195 1195
 
1196 1196
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 
1206 1206
 	private static function add_time_to_date( $time_format, $date ) {
1207 1207
 		if ( empty( $time_format ) ) {
1208
-			$time_format = get_option('time_format');
1208
+			$time_format = get_option( 'time_format' );
1209 1209
 		}
1210 1210
 
1211 1211
 		$trimmed_format = trim( $time_format );
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
      * @return string The time ago in words
1230 1230
      */
1231 1231
     public static function human_time_diff( $from, $to = '' ) {
1232
-    	if ( empty($to) ) {
1232
+    	if ( empty( $to ) ) {
1233 1233
     	    		$to = time();
1234 1234
     	}
1235 1235
 
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
     	);
1246 1246
 
1247 1247
     	// Difference in seconds
1248
-    	$diff = (int) ($to - $from);
1248
+    	$diff = (int) ( $to - $from );
1249 1249
 
1250 1250
     	// Something went wrong with date calculation and we ended up with a negative date.
1251 1251
 		if ( $diff < 1 ) {
@@ -1262,17 +1262,17 @@  discard block
 block discarded – undo
1262 1262
         $count = 0;
1263 1263
 
1264 1264
     	//Step one: the first chunk
1265
-		for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) {
1266
-    		$seconds = $chunks[ $i ][0];
1265
+		for ( $i = 0, $j = count( $chunks ); $i < $j; $i ++ ) {
1266
+    		$seconds = $chunks[$i][0];
1267 1267
 
1268 1268
     		// Finding the biggest chunk (if the chunk fits, break)
1269
-    		if ( ( $count = floor($diff / $seconds) ) != 0 ) {
1269
+    		if ( ( $count = floor( $diff / $seconds ) ) != 0 ) {
1270 1270
     		    			break;
1271 1271
     		}
1272 1272
     	}
1273 1273
 
1274 1274
     	// Set output var
1275
-    	$output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2];
1275
+    	$output = ( 1 == $count ) ? '1 ' . $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
1276 1276
 
1277 1277
     	if ( ! (int) trim( $output ) ) {
1278 1278
     		$output = '0 ' . __( 'seconds', 'formidable' );
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
      */
1292 1292
 	public static function esc_like( $term ) {
1293 1293
         global $wpdb;
1294
-        if ( method_exists($wpdb, 'esc_like') ) {
1294
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1295 1295
 			// WP 4.0
1296 1296
             $term = $wpdb->esc_like( $term );
1297 1297
         } else {
@@ -1305,17 +1305,17 @@  discard block
 block discarded – undo
1305 1305
      * @param string $order_query
1306 1306
      */
1307 1307
 	public static function esc_order( $order_query ) {
1308
-        if ( empty($order_query) ) {
1308
+        if ( empty( $order_query ) ) {
1309 1309
             return '';
1310 1310
         }
1311 1311
 
1312 1312
         // remove ORDER BY before santizing
1313
-        $order_query = strtolower($order_query);
1314
-        if ( strpos($order_query, 'order by') !== false ) {
1315
-            $order_query = str_replace('order by', '', $order_query);
1313
+        $order_query = strtolower( $order_query );
1314
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1315
+            $order_query = str_replace( 'order by', '', $order_query );
1316 1316
         }
1317 1317
 
1318
-        $order_query = explode(' ', trim($order_query));
1318
+        $order_query = explode( ' ', trim( $order_query ) );
1319 1319
 
1320 1320
         $order_fields = array(
1321 1321
             'id', 'form_key', 'name', 'description',
@@ -1323,18 +1323,18 @@  discard block
 block discarded – undo
1323 1323
             'default_template', 'status', 'created_at',
1324 1324
         );
1325 1325
 
1326
-        $order = trim(trim(reset($order_query), ','));
1327
-        if ( ! in_array($order, $order_fields) ) {
1326
+        $order = trim( trim( reset( $order_query ), ',' ) );
1327
+        if ( ! in_array( $order, $order_fields ) ) {
1328 1328
             return '';
1329 1329
         }
1330 1330
 
1331 1331
         $order_by = '';
1332
-        if ( count($order_query) > 1 ) {
1332
+        if ( count( $order_query ) > 1 ) {
1333 1333
 			$order_by = end( $order_query );
1334 1334
 			self::esc_order_by( $order_by );
1335 1335
         }
1336 1336
 
1337
-        return ' ORDER BY '. $order . ' '. $order_by;
1337
+        return ' ORDER BY ' . $order . ' ' . $order_by;
1338 1338
     }
1339 1339
 
1340 1340
 	/**
@@ -1351,24 +1351,24 @@  discard block
 block discarded – undo
1351 1351
      * @param string $limit
1352 1352
      */
1353 1353
 	public static function esc_limit( $limit ) {
1354
-        if ( empty($limit) ) {
1354
+        if ( empty( $limit ) ) {
1355 1355
             return '';
1356 1356
         }
1357 1357
 
1358
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1359
-        if ( is_numeric($limit) ) {
1360
-            return ' LIMIT '. $limit;
1358
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1359
+        if ( is_numeric( $limit ) ) {
1360
+            return ' LIMIT ' . $limit;
1361 1361
         }
1362 1362
 
1363
-        $limit = explode(',', trim($limit));
1363
+        $limit = explode( ',', trim( $limit ) );
1364 1364
         foreach ( $limit as $k => $l ) {
1365 1365
             if ( is_numeric( $l ) ) {
1366
-                $limit[ $k ] = $l;
1366
+                $limit[$k] = $l;
1367 1367
             }
1368 1368
         }
1369 1369
 
1370
-        $limit = implode(',', $limit);
1371
-        return ' LIMIT '. $limit;
1370
+        $limit = implode( ',', $limit );
1371
+        return ' LIMIT ' . $limit;
1372 1372
     }
1373 1373
 
1374 1374
     /**
@@ -1376,12 +1376,12 @@  discard block
 block discarded – undo
1376 1376
      * @since 2.0
1377 1377
      */
1378 1378
     public static function prepare_array_values( $array, $type = '%s' ) {
1379
-        $placeholders = array_fill(0, count($array), $type);
1380
-        return implode(', ', $placeholders);
1379
+        $placeholders = array_fill( 0, count( $array ), $type );
1380
+        return implode( ', ', $placeholders );
1381 1381
     }
1382 1382
 
1383 1383
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1384
-        if ( empty($where) ) {
1384
+        if ( empty( $where ) ) {
1385 1385
             return '';
1386 1386
         }
1387 1387
 
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 
1428 1428
     public static function get_referer_info() {
1429 1429
         _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1430
-        return self::get_server_value('HTTP_REFERER');
1430
+        return self::get_server_value( 'HTTP_REFERER' );
1431 1431
     }
1432 1432
 
1433 1433
 	/**
@@ -1436,19 +1436,19 @@  discard block
 block discarded – undo
1436 1436
 	public static function json_to_array( $json_vars ) {
1437 1437
         $vars = array();
1438 1438
         foreach ( $json_vars as $jv ) {
1439
-            $jv_name = explode('[', $jv['name']);
1440
-            $last = count($jv_name) - 1;
1439
+            $jv_name = explode( '[', $jv['name'] );
1440
+            $last = count( $jv_name ) - 1;
1441 1441
             foreach ( $jv_name as $p => $n ) {
1442
-                $name = trim($n, ']');
1443
-                if ( ! isset($l1) ) {
1442
+                $name = trim( $n, ']' );
1443
+                if ( ! isset( $l1 ) ) {
1444 1444
                     $l1 = $name;
1445 1445
                 }
1446 1446
 
1447
-                if ( ! isset($l2) ) {
1447
+                if ( ! isset( $l2 ) ) {
1448 1448
                     $l2 = $name;
1449 1449
                 }
1450 1450
 
1451
-                if ( ! isset($l3) ) {
1451
+                if ( ! isset( $l3 ) ) {
1452 1452
                     $l3 = $name;
1453 1453
                 }
1454 1454
 
@@ -1462,24 +1462,24 @@  discard block
 block discarded – undo
1462 1462
 
1463 1463
                     case 1:
1464 1464
                         $l2 = $name;
1465
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1465
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1466 1466
                     break;
1467 1467
 
1468 1468
                     case 2:
1469 1469
                         $l3 = $name;
1470
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1470
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1471 1471
                     break;
1472 1472
 
1473 1473
                     case 3:
1474 1474
                         $l4 = $name;
1475
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1475
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1476 1476
                     break;
1477 1477
                 }
1478 1478
 
1479
-                unset($this_val, $n);
1479
+                unset( $this_val, $n );
1480 1480
             }
1481 1481
 
1482
-            unset($last, $jv);
1482
+            unset( $last, $jv );
1483 1483
         }
1484 1484
 
1485 1485
         return $vars;
@@ -1492,8 +1492,8 @@  discard block
 block discarded – undo
1492 1492
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1493 1493
         if ( $name == '' ) {
1494 1494
             $vars[] = $val;
1495
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1496
-            $vars[ $l1 ] = $val;
1495
+        } else if ( ! isset( $vars[$l1] ) ) {
1496
+            $vars[$l1] = $val;
1497 1497
         }
1498 1498
     }
1499 1499
 
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
             '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() ) ),
1509 1509
         );
1510 1510
 
1511
-        if ( ! isset( $tooltips[ $name ] ) ) {
1511
+        if ( ! isset( $tooltips[$name] ) ) {
1512 1512
             return;
1513 1513
         }
1514 1514
 
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
             echo ' class="frm_help"';
1519 1519
         }
1520 1520
 
1521
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1521
+        echo ' title="' . esc_attr( $tooltips[$name] );
1522 1522
 
1523 1523
         if ( 'open' != $class ) {
1524 1524
             echo '"';
@@ -1570,13 +1570,13 @@  discard block
 block discarded – undo
1570 1570
     }
1571 1571
 
1572 1572
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1573
-		if ( ! isset( $post_content[ $key ] ) ) {
1573
+		if ( ! isset( $post_content[$key] ) ) {
1574 1574
 			return;
1575 1575
 		}
1576 1576
 
1577 1577
 		if ( is_array( $val ) ) {
1578 1578
 			foreach ( $val as $k1 => $v1 ) {
1579
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1579
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1580 1580
 				unset( $k1, $v1 );
1581 1581
 			}
1582 1582
 		} else {
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 			$val = stripslashes( $val );
1585 1585
 
1586 1586
 			// Add backslashes before double quotes and forward slashes only
1587
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1587
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1588 1588
 		}
1589 1589
 	}
1590 1590
 
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1602 1602
 
1603 1603
 		if ( empty( $settings['ID'] ) ) {
1604
-			unset( $settings['ID']);
1604
+			unset( $settings['ID'] );
1605 1605
 		}
1606 1606
 
1607 1607
 		// delete all caches for this group
@@ -1635,17 +1635,17 @@  discard block
 block discarded – undo
1635 1635
 	}
1636 1636
 
1637 1637
 	public static function maybe_json_decode( $string ) {
1638
-        if ( is_array($string) ) {
1638
+        if ( is_array( $string ) ) {
1639 1639
             return $string;
1640 1640
         }
1641 1641
 
1642
-        $new_string = json_decode($string, true);
1643
-        if ( function_exists('json_last_error') ) {
1642
+        $new_string = json_decode( $string, true );
1643
+        if ( function_exists( 'json_last_error' ) ) {
1644 1644
 			// php 5.3+
1645 1645
             if ( json_last_error() == JSON_ERROR_NONE ) {
1646 1646
                 $string = $new_string;
1647 1647
             }
1648
-        } else if ( isset($new_string) ) {
1648
+        } else if ( isset( $new_string ) ) {
1649 1649
 			// php < 5.3 fallback
1650 1650
             $string = $new_string;
1651 1651
         }
@@ -1661,11 +1661,11 @@  discard block
 block discarded – undo
1661 1661
 	public static function maybe_highlight_menu( $post_type ) {
1662 1662
         global $post, $pagenow;
1663 1663
 
1664
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1664
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1665 1665
             return;
1666 1666
         }
1667 1667
 
1668
-        if ( is_object($post) && $post->post_type != $post_type ) {
1668
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1669 1669
             return;
1670 1670
         }
1671 1671
 
@@ -1763,11 +1763,11 @@  discard block
 block discarded – undo
1763 1763
         $frm_version = self::plugin_version();
1764 1764
 
1765 1765
         // check if Formidable meets minimum requirements
1766
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1766
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1767 1767
             return;
1768 1768
         }
1769 1769
 
1770
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1770
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1771 1771
 		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">' .
1772 1772
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1773 1773
         '</div></td></tr>';
@@ -1775,38 +1775,38 @@  discard block
 block discarded – undo
1775 1775
 
1776 1776
     public static function locales( $type = 'date' ) {
1777 1777
         $locales = array(
1778
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1779
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1780
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1778
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1779
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1780
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1781 1781
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1782
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1783
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1782
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1783
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1784 1784
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1785
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1786
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1785
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1786
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1787 1787
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1788
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1788
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1789 1789
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1790
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1790
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1791 1791
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1792
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1792
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1793 1793
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1794
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1795
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1796
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1797
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1798
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1794
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1795
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1796
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1797
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1798
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1799 1799
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1800
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1800
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1801 1801
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1802 1802
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1803
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1803
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1804 1804
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1805
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1805
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1806 1806
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1807
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1808
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1809
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1807
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1808
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1809
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1810 1810
         );
1811 1811
 
1812 1812
         if ( $type == 'captcha' ) {
@@ -1825,8 +1825,8 @@  discard block
 block discarded – undo
1825 1825
             );
1826 1826
         }
1827 1827
 
1828
-        $locales = array_diff_key($locales, array_flip($unset));
1829
-        $locales = apply_filters('frm_locales', $locales);
1828
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1829
+        $locales = apply_filters( 'frm_locales', $locales );
1830 1830
 
1831 1831
         return $locales;
1832 1832
     }
Please login to merge, or discard this patch.
Indentation   +1180 added lines, -1180 removed lines patch added patch discarded remove patch
@@ -12,127 +12,127 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.0.19b3';
14 14
 
15
-    /**
16
-     * @since 1.07.02
17
-     *
18
-     * @param none
19
-     * @return string The version of this plugin
20
-     */
21
-    public static function plugin_version() {
22
-        return self::$plug_version;
23
-    }
24
-
25
-    public static function plugin_folder() {
26
-        return basename(self::plugin_path());
27
-    }
28
-
29
-    public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
31
-    }
32
-
33
-    public static function plugin_url() {
34
-        //prevously FRM_URL constant
35
-        return plugins_url( '', self::plugin_path() .'/formidable.php' );
36
-    }
15
+	/**
16
+	 * @since 1.07.02
17
+	 *
18
+	 * @param none
19
+	 * @return string The version of this plugin
20
+	 */
21
+	public static function plugin_version() {
22
+		return self::$plug_version;
23
+	}
24
+
25
+	public static function plugin_folder() {
26
+		return basename(self::plugin_path());
27
+	}
28
+
29
+	public static function plugin_path() {
30
+		return dirname(dirname(dirname(__FILE__)));
31
+	}
32
+
33
+	public static function plugin_url() {
34
+		//prevously FRM_URL constant
35
+		return plugins_url( '', self::plugin_path() .'/formidable.php' );
36
+	}
37 37
 
38 38
 	public static function relative_plugin_url() {
39 39
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
40 40
 	}
41 41
 
42
-    /**
43
-     * @return string Site URL
44
-     */
45
-    public static function site_url() {
46
-        return site_url();
47
-    }
48
-
49
-    /**
50
-     * Get the name of this site
51
-     * Used for [sitename] shortcode
52
-     *
53
-     * @since 2.0
54
-     * @return string
55
-     */
56
-    public static function site_name() {
57
-        return get_option('blogname');
58
-    }
42
+	/**
43
+	 * @return string Site URL
44
+	 */
45
+	public static function site_url() {
46
+		return site_url();
47
+	}
48
+
49
+	/**
50
+	 * Get the name of this site
51
+	 * Used for [sitename] shortcode
52
+	 *
53
+	 * @since 2.0
54
+	 * @return string
55
+	 */
56
+	public static function site_name() {
57
+		return get_option('blogname');
58
+	}
59 59
 
60 60
 	public static function affiliate() {
61 61
 		return '';
62 62
 	}
63 63
 
64
-    /**
65
-     * Get the Formidable settings
66
-     *
67
-     * @since 2.0
68
-     *
69
-     * @param None
70
-     * @return FrmSettings $frm_setings
71
-     */
72
-    public static function get_settings() {
73
-        global $frm_settings;
74
-        if ( empty($frm_settings) ) {
75
-            $frm_settings = new FrmSettings();
76
-        }
77
-        return $frm_settings;
78
-    }
79
-
80
-    /**
81
-     * Show a message in place of pro features
82
-     *
83
-     * @since 2.0
84
-     */
64
+	/**
65
+	 * Get the Formidable settings
66
+	 *
67
+	 * @since 2.0
68
+	 *
69
+	 * @param None
70
+	 * @return FrmSettings $frm_setings
71
+	 */
72
+	public static function get_settings() {
73
+		global $frm_settings;
74
+		if ( empty($frm_settings) ) {
75
+			$frm_settings = new FrmSettings();
76
+		}
77
+		return $frm_settings;
78
+	}
79
+
80
+	/**
81
+	 * Show a message in place of pro features
82
+	 *
83
+	 * @since 2.0
84
+	 */
85 85
 	public static function update_message( $features, $class = '' ) {
86 86
 		_deprecated_function( __FUNCTION__, '2.0.19' );
87
-    }
88
-
89
-    public static function pro_is_installed() {
90
-        return apply_filters('frm_pro_installed', false);
91
-    }
92
-
93
-    /**
94
-     * Check for certain page in Formidable settings
95
-     *
96
-     * @since 2.0
97
-     *
98
-     * @param string $page The name of the page to check
99
-     * @return boolean
100
-     */
87
+	}
88
+
89
+	public static function pro_is_installed() {
90
+		return apply_filters('frm_pro_installed', false);
91
+	}
92
+
93
+	/**
94
+	 * Check for certain page in Formidable settings
95
+	 *
96
+	 * @since 2.0
97
+	 *
98
+	 * @param string $page The name of the page to check
99
+	 * @return boolean
100
+	 */
101 101
 	public static function is_admin_page( $page = 'formidable' ) {
102
-        global $pagenow;
102
+		global $pagenow;
103 103
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
104
-        if ( $pagenow ) {
104
+		if ( $pagenow ) {
105 105
 			return $pagenow == 'admin.php' && $get_page == $page;
106
-        }
106
+		}
107 107
 
108 108
 		return is_admin() && $get_page == $page;
109
-    }
110
-
111
-    /**
112
-     * Check for the form preview page
113
-     *
114
-     * @since 2.0
115
-     *
116
-     * @param None
117
-     * @return boolean
118
-     */
119
-    public static function is_preview_page() {
120
-        global $pagenow;
109
+	}
110
+
111
+	/**
112
+	 * Check for the form preview page
113
+	 *
114
+	 * @since 2.0
115
+	 *
116
+	 * @param None
117
+	 * @return boolean
118
+	 */
119
+	public static function is_preview_page() {
120
+		global $pagenow;
121 121
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
122 122
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
123
-    }
123
+	}
124 124
 
125
-    /**
126
-     * Check for ajax except the form preview page
127
-     *
128
-     * @since 2.0
129
-     *
130
-     * @param None
131
-     * @return boolean
132
-     */
133
-    public static function doing_ajax() {
134
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
135
-    }
125
+	/**
126
+	 * Check for ajax except the form preview page
127
+	 *
128
+	 * @since 2.0
129
+	 *
130
+	 * @param None
131
+	 * @return boolean
132
+	 */
133
+	public static function doing_ajax() {
134
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
135
+	}
136 136
 
137 137
 	/**
138 138
 	 * @since 2.0.8
@@ -142,101 +142,101 @@  discard block
 block discarded – undo
142 142
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
143 143
 	}
144 144
 
145
-    /**
146
-     * Check if on an admin page
147
-     *
148
-     * @since 2.0
149
-     *
150
-     * @param None
151
-     * @return boolean
152
-     */
153
-    public static function is_admin() {
154
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
155
-    }
156
-
157
-    /**
158
-     * Check if value contains blank value or empty array
159
-     *
160
-     * @since 2.0
161
-     * @param $value - value to check
162
-     * @return boolean
163
-     */
164
-    public static function is_empty_value( $value, $empty = '' ) {
165
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
166
-    }
167
-
168
-    public static function is_not_empty_value( $value, $empty = '' ) {
169
-        return ! self::is_empty_value( $value, $empty );
170
-    }
171
-
172
-    /**
173
-     * Get any value from the $_SERVER
174
-     *
175
-     * @since 2.0
176
-     * @param string $value
177
-     * @return string
178
-     */
145
+	/**
146
+	 * Check if on an admin page
147
+	 *
148
+	 * @since 2.0
149
+	 *
150
+	 * @param None
151
+	 * @return boolean
152
+	 */
153
+	public static function is_admin() {
154
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
155
+	}
156
+
157
+	/**
158
+	 * Check if value contains blank value or empty array
159
+	 *
160
+	 * @since 2.0
161
+	 * @param $value - value to check
162
+	 * @return boolean
163
+	 */
164
+	public static function is_empty_value( $value, $empty = '' ) {
165
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
166
+	}
167
+
168
+	public static function is_not_empty_value( $value, $empty = '' ) {
169
+		return ! self::is_empty_value( $value, $empty );
170
+	}
171
+
172
+	/**
173
+	 * Get any value from the $_SERVER
174
+	 *
175
+	 * @since 2.0
176
+	 * @param string $value
177
+	 * @return string
178
+	 */
179 179
 	public static function get_server_value( $value ) {
180
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
181
-    }
182
-
183
-    /**
184
-     * Check for the IP address in several places
185
-     * Used by [ip] shortcode
186
-     *
187
-     * @return string The IP address of the current user
188
-     */
189
-    public static function get_ip_address() {
180
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
181
+	}
182
+
183
+	/**
184
+	 * Check for the IP address in several places
185
+	 * Used by [ip] shortcode
186
+	 *
187
+	 * @return string The IP address of the current user
188
+	 */
189
+	public static function get_ip_address() {
190 190
 		$ip = '';
191
-        foreach ( array(
192
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
193
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
194
-        ) as $key ) {
195
-            if ( ! isset( $_SERVER[ $key ] ) ) {
196
-                continue;
197
-            }
198
-
199
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
200
-                $ip = trim($ip); // just to be safe
201
-
202
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
203
-                    return $ip;
204
-                }
205
-            }
206
-        }
191
+		foreach ( array(
192
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
193
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
194
+		) as $key ) {
195
+			if ( ! isset( $_SERVER[ $key ] ) ) {
196
+				continue;
197
+			}
198
+
199
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
200
+				$ip = trim($ip); // just to be safe
201
+
202
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
203
+					return $ip;
204
+				}
205
+			}
206
+		}
207 207
 
208 208
 		return sanitize_text_field( $ip );
209
-    }
209
+	}
210 210
 
211
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
212
-        if ( strpos($param, '[') ) {
213
-            $params = explode('[', $param);
214
-            $param = $params[0];
215
-        }
211
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
212
+		if ( strpos($param, '[') ) {
213
+			$params = explode('[', $param);
214
+			$param = $params[0];
215
+		}
216 216
 
217 217
 		if ( $src == 'get' ) {
218
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
219
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
220
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
221
-            }
218
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
219
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
220
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
221
+			}
222 222
 			self::sanitize_value( $sanitize, $value );
223 223
 		} else {
224
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
225
-        }
224
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
225
+		}
226 226
 
227 227
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
228
-            foreach ( $params as $k => $p ) {
229
-                if ( ! $k || ! is_array($value) ) {
230
-                    continue;
231
-                }
228
+			foreach ( $params as $k => $p ) {
229
+				if ( ! $k || ! is_array($value) ) {
230
+					continue;
231
+				}
232 232
 
233
-                $p = trim($p, ']');
234
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
235
-            }
236
-        }
233
+				$p = trim($p, ']');
234
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
235
+			}
236
+		}
237 237
 
238
-        return $value;
239
-    }
238
+		return $value;
239
+	}
240 240
 
241 241
 	/**
242 242
 	 *
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 */
258 258
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
259 259
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
260
-    }
260
+	}
261 261
 
262 262
 	/**
263 263
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 	}
292 292
 
293 293
 	/**
294
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
295
-	*
296
-	* @since 2.0.8
297
-	* @param string $value
298
-	* @return string $value
299
-	*/
294
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
295
+	 *
296
+	 * @since 2.0.8
297
+	 * @param string $value
298
+	 * @return string $value
299
+	 */
300 300
 	public static function preserve_backslashes( $value ) {
301 301
 		// If backslashes have already been added, don't add them again
302 302
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
 		}
316 316
 	}
317 317
 
318
-    public static function sanitize_request( $sanitize_method, &$values ) {
319
-        $temp_values = $values;
320
-        foreach ( $temp_values as $k => $val ) {
321
-            if ( isset( $sanitize_method[ $k ] ) ) {
318
+	public static function sanitize_request( $sanitize_method, &$values ) {
319
+		$temp_values = $values;
320
+		foreach ( $temp_values as $k => $val ) {
321
+			if ( isset( $sanitize_method[ $k ] ) ) {
322 322
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
323
-            }
324
-        }
325
-    }
323
+			}
324
+		}
325
+	}
326 326
 
327 327
 	public static function sanitize_array( &$values ) {
328 328
 		$temp_values = $values;
@@ -337,12 +337,12 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	public static function kses( $value, $allowed = array() ) {
339 339
 		$html = array(
340
-		    'a' => array(
340
+			'a' => array(
341 341
 				'href'  => array(),
342 342
 				'title' => array(),
343 343
 				'id'    => array(),
344 344
 				'class' => array(),
345
-		    ),
345
+			),
346 346
 		);
347 347
 
348 348
 		$allowed_html = array();
@@ -353,176 +353,176 @@  discard block
 block discarded – undo
353 353
 		return wp_kses( $value, $allowed_html );
354 354
 	}
355 355
 
356
-    /**
357
-     * Used when switching the action for a bulk action
358
-     * @since 2.0
359
-     */
360
-    public static function remove_get_action() {
361
-        if ( ! isset($_GET) ) {
362
-            return;
363
-        }
356
+	/**
357
+	 * Used when switching the action for a bulk action
358
+	 * @since 2.0
359
+	 */
360
+	public static function remove_get_action() {
361
+		if ( ! isset($_GET) ) {
362
+			return;
363
+		}
364 364
 
365
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
366
-        if ( ! empty( $new_action ) ) {
365
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
366
+		if ( ! empty( $new_action ) ) {
367 367
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
368
-        }
369
-    }
370
-
371
-    /**
372
-     * Check the WP query for a parameter
373
-     *
374
-     * @since 2.0
375
-     * @return string|array
376
-     */
377
-    public static function get_query_var( $value, $param ) {
378
-        if ( $value != '' ) {
379
-            return $value;
380
-        }
381
-
382
-        global $wp_query;
383
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
384
-            $value = $wp_query->query_vars[ $param ];
385
-        }
386
-
387
-        return $value;
388
-    }
389
-
390
-    /**
391
-     * @param string $type
392
-     */
393
-    public static function trigger_hook_load( $type, $object = null ) {
394
-        // only load the form hooks once
395
-        $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
396
-        if ( ! $hooks_loaded ) {
397
-            do_action('frm_load_'. $type .'_hooks');
398
-        }
399
-    }
400
-
401
-    /**
402
-     * Check cache before fetching values and saving to cache
403
-     *
404
-     * @since 2.0
405
-     *
406
-     * @param string $cache_key The unique name for this cache
407
-     * @param string $group The name of the cache group
408
-     * @param string $query If blank, don't run a db call
409
-     * @param string $type The wpdb function to use with this query
410
-     * @return mixed $results The cache or query results
411
-     */
412
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
413
-        $results = wp_cache_get($cache_key, $group);
414
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
415
-            return $results;
416
-        }
417
-
418
-        if ( 'get_posts' == $type ) {
419
-            $results = get_posts($query);
420
-        } else {
421
-            global $wpdb;
422
-            $results = $wpdb->{$type}($query);
423
-        }
368
+		}
369
+	}
370
+
371
+	/**
372
+	 * Check the WP query for a parameter
373
+	 *
374
+	 * @since 2.0
375
+	 * @return string|array
376
+	 */
377
+	public static function get_query_var( $value, $param ) {
378
+		if ( $value != '' ) {
379
+			return $value;
380
+		}
381
+
382
+		global $wp_query;
383
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
384
+			$value = $wp_query->query_vars[ $param ];
385
+		}
386
+
387
+		return $value;
388
+	}
389
+
390
+	/**
391
+	 * @param string $type
392
+	 */
393
+	public static function trigger_hook_load( $type, $object = null ) {
394
+		// only load the form hooks once
395
+		$hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
396
+		if ( ! $hooks_loaded ) {
397
+			do_action('frm_load_'. $type .'_hooks');
398
+		}
399
+	}
400
+
401
+	/**
402
+	 * Check cache before fetching values and saving to cache
403
+	 *
404
+	 * @since 2.0
405
+	 *
406
+	 * @param string $cache_key The unique name for this cache
407
+	 * @param string $group The name of the cache group
408
+	 * @param string $query If blank, don't run a db call
409
+	 * @param string $type The wpdb function to use with this query
410
+	 * @return mixed $results The cache or query results
411
+	 */
412
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
413
+		$results = wp_cache_get($cache_key, $group);
414
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
415
+			return $results;
416
+		}
417
+
418
+		if ( 'get_posts' == $type ) {
419
+			$results = get_posts($query);
420
+		} else {
421
+			global $wpdb;
422
+			$results = $wpdb->{$type}($query);
423
+		}
424 424
 
425 425
 		if ( ! self::prevent_caching() ) {
426 426
 			wp_cache_set( $cache_key, $results, $group, $time );
427 427
 		}
428 428
 
429
-        return $results;
430
-    }
429
+		return $results;
430
+	}
431 431
 
432
-    /**
433
-     * Data that should be stored for a long time can be stored in a transient.
434
-     * First check the cache, then check the transient
435
-     * @since 2.0
436
-     * @return mixed The cached value or false
437
-     */
432
+	/**
433
+	 * Data that should be stored for a long time can be stored in a transient.
434
+	 * First check the cache, then check the transient
435
+	 * @since 2.0
436
+	 * @return mixed The cached value or false
437
+	 */
438 438
 	public static function check_cache_and_transient( $cache_key ) {
439
-        // check caching layer first
440
-        $results = self::check_cache( $cache_key );
441
-        if ( $results ) {
442
-            return $results;
443
-        }
444
-
445
-        // then check the transient
446
-        $results = get_transient($cache_key);
447
-        if ( $results ) {
448
-            wp_cache_set($cache_key, $results);
449
-        }
450
-
451
-        return $results;
452
-    }
453
-
454
-    /**
455
-     * @since 2.0
456
-     * @param string $cache_key
457
-     */
439
+		// check caching layer first
440
+		$results = self::check_cache( $cache_key );
441
+		if ( $results ) {
442
+			return $results;
443
+		}
444
+
445
+		// then check the transient
446
+		$results = get_transient($cache_key);
447
+		if ( $results ) {
448
+			wp_cache_set($cache_key, $results);
449
+		}
450
+
451
+		return $results;
452
+	}
453
+
454
+	/**
455
+	 * @since 2.0
456
+	 * @param string $cache_key
457
+	 */
458 458
 	public static function delete_cache_and_transient( $cache_key ) {
459
-        delete_transient($cache_key);
460
-        wp_cache_delete($cache_key);
461
-    }
462
-
463
-    /**
464
-     * Delete all caching in a single group
465
-     *
466
-     * @since 2.0
467
-     *
468
-     * @param string $group The name of the cache group
469
-     * @return boolean True or False
470
-     */
459
+		delete_transient($cache_key);
460
+		wp_cache_delete($cache_key);
461
+	}
462
+
463
+	/**
464
+	 * Delete all caching in a single group
465
+	 *
466
+	 * @since 2.0
467
+	 *
468
+	 * @param string $group The name of the cache group
469
+	 * @return boolean True or False
470
+	 */
471 471
 	public static function cache_delete_group( $group ) {
472
-    	global $wp_object_cache;
473
-
474
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
475
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
476
-                wp_cache_delete($k, $group);
477
-            }
478
-            return true;
479
-        }
480
-
481
-    	return false;
482
-    }
483
-
484
-    /**
485
-     * Check a value from a shortcode to see if true or false.
486
-     * True when value is 1, true, 'true', 'yes'
487
-     *
488
-     * @since 1.07.10
489
-     *
490
-     * @param string $value The value to compare
491
-     * @return boolean True or False
492
-     */
472
+		global $wp_object_cache;
473
+
474
+		if ( isset( $wp_object_cache->cache[ $group ] ) ) {
475
+			foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
476
+				wp_cache_delete($k, $group);
477
+			}
478
+			return true;
479
+		}
480
+
481
+		return false;
482
+	}
483
+
484
+	/**
485
+	 * Check a value from a shortcode to see if true or false.
486
+	 * True when value is 1, true, 'true', 'yes'
487
+	 *
488
+	 * @since 1.07.10
489
+	 *
490
+	 * @param string $value The value to compare
491
+	 * @return boolean True or False
492
+	 */
493 493
 	public static function is_true( $value ) {
494
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
495
-    }
494
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
495
+	}
496 496
 
497
-    /**
498
-     * Used to filter shortcode in text widgets
499
-     */
500
-    public static function widget_text_filter_callback( $matches ) {
501
-        return do_shortcode( $matches[0] );
502
-    }
497
+	/**
498
+	 * Used to filter shortcode in text widgets
499
+	 */
500
+	public static function widget_text_filter_callback( $matches ) {
501
+		return do_shortcode( $matches[0] );
502
+	}
503 503
 
504 504
 	public static function load_scripts( $scripts ) {
505
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
506
-        foreach ( (array) $scripts as $s ) {
507
-            wp_enqueue_script($s);
508
-        }
509
-    }
505
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
506
+		foreach ( (array) $scripts as $s ) {
507
+			wp_enqueue_script($s);
508
+		}
509
+	}
510 510
 
511 511
 	public static function load_styles( $styles ) {
512
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
513
-        foreach ( (array) $styles as $s ) {
514
-            wp_enqueue_style($s);
515
-        }
516
-    }
512
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
513
+		foreach ( (array) $styles as $s ) {
514
+			wp_enqueue_style($s);
515
+		}
516
+	}
517 517
 
518
-    public static function get_pages() {
518
+	public static function get_pages() {
519 519
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
520
-    }
520
+	}
521 521
 
522
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
523
-        $pages = self::get_pages();
522
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
523
+		$pages = self::get_pages();
524 524
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
525
-    ?>
525
+	?>
526 526
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
527 527
             <option value=""> </option>
528 528
             <?php foreach ( $pages as $page ) { ?>
@@ -532,107 +532,107 @@  discard block
 block discarded – undo
532 532
             <?php } ?>
533 533
         </select>
534 534
     <?php
535
-    }
535
+	}
536 536
 
537 537
 	public static function post_edit_link( $post_id ) {
538
-        $post = get_post($post_id);
539
-        if ( $post ) {
540
-            return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
541
-        }
542
-        return '';
543
-    }
538
+		$post = get_post($post_id);
539
+		if ( $post ) {
540
+			return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
541
+		}
542
+		return '';
543
+	}
544 544
 
545 545
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
546
-    ?>
546
+	?>
547 547
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
548
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
549
-            ?> class="frm_multiselect">
548
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
549
+			?> class="frm_multiselect">
550 550
             <?php self::roles_options($capability); ?>
551 551
         </select>
552 552
     <?php
553
-    }
553
+	}
554 554
 
555 555
 	public static function roles_options( $capability ) {
556
-        global $frm_vars;
557
-        if ( isset($frm_vars['editable_roles']) ) {
558
-            $editable_roles = $frm_vars['editable_roles'];
559
-        } else {
560
-            $editable_roles = get_editable_roles();
561
-            $frm_vars['editable_roles'] = $editable_roles;
562
-        }
563
-
564
-        foreach ( $editable_roles as $role => $details ) {
565
-            $name = translate_user_role($details['name'] ); ?>
556
+		global $frm_vars;
557
+		if ( isset($frm_vars['editable_roles']) ) {
558
+			$editable_roles = $frm_vars['editable_roles'];
559
+		} else {
560
+			$editable_roles = get_editable_roles();
561
+			$frm_vars['editable_roles'] = $editable_roles;
562
+		}
563
+
564
+		foreach ( $editable_roles as $role => $details ) {
565
+			$name = translate_user_role($details['name'] ); ?>
566 566
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
567 567
 <?php
568
-            unset($role, $details);
569
-        }
570
-    }
568
+			unset($role, $details);
569
+		}
570
+	}
571 571
 
572 572
 	public static function frm_capabilities( $type = 'auto' ) {
573
-        $cap = array(
574
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
575
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
576
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
577
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
578
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
579
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
580
-        );
573
+		$cap = array(
574
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
575
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
576
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
577
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
578
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
579
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
580
+		);
581 581
 
582 582
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
583
-            return $cap;
584
-        }
583
+			return $cap;
584
+		}
585 585
 
586
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
587
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
588
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
589
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
586
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
587
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
588
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
589
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
590 590
 
591
-        return $cap;
592
-    }
591
+		return $cap;
592
+	}
593 593
 
594 594
 	public static function user_has_permission( $needed_role ) {
595
-        if ( $needed_role == '-1' ) {
596
-            return false;
595
+		if ( $needed_role == '-1' ) {
596
+			return false;
597 597
 		}
598 598
 
599
-        // $needed_role will be equal to blank if "Logged-in users" is selected
600
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
601
-            return true;
602
-        }
599
+		// $needed_role will be equal to blank if "Logged-in users" is selected
600
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
601
+			return true;
602
+		}
603 603
 
604
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
605
-        foreach ( $roles as $role ) {
604
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
605
+		foreach ( $roles as $role ) {
606 606
 			if ( current_user_can( $role ) ) {
607
-        		return true;
607
+				return true;
608 608
 			}
609
-        	if ( $role == $needed_role ) {
610
-        		break;
609
+			if ( $role == $needed_role ) {
610
+				break;
611 611
 			}
612
-        }
613
-        return false;
614
-    }
615
-
616
-    /**
617
-     * Make sure administrators can see Formidable menu
618
-     *
619
-     * @since 2.0
620
-     */
621
-    public static function maybe_add_permissions() {
612
+		}
613
+		return false;
614
+	}
615
+
616
+	/**
617
+	 * Make sure administrators can see Formidable menu
618
+	 *
619
+	 * @since 2.0
620
+	 */
621
+	public static function maybe_add_permissions() {
622 622
 		self::force_capability( 'frm_view_entries' );
623 623
 
624
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
625
-            return;
626
-        }
624
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
625
+			return;
626
+		}
627 627
 
628 628
 		$user_id = get_current_user_id();
629 629
 		$user = new WP_User( $user_id );
630
-        $frm_roles = self::frm_capabilities();
631
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
630
+		$frm_roles = self::frm_capabilities();
631
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
632 632
 			$user->add_cap( $frm_role );
633
-            unset($frm_role, $frm_role_description);
634
-        }
635
-    }
633
+			unset($frm_role, $frm_role_description);
634
+		}
635
+	}
636 636
 
637 637
 	/**
638 638
 	 * Make sure admins have permission to see the menu items
@@ -648,28 +648,28 @@  discard block
 block discarded – undo
648 648
 		}
649 649
 	}
650 650
 
651
-    /**
652
-     * Check if the user has permision for action.
653
-     * Return permission message and stop the action if no permission
654
-     * @since 2.0
655
-     * @param string $permission
656
-     */
651
+	/**
652
+	 * Check if the user has permision for action.
653
+	 * Return permission message and stop the action if no permission
654
+	 * @since 2.0
655
+	 * @param string $permission
656
+	 */
657 657
 	public static function permission_check( $permission, $show_message = 'show' ) {
658
-        $permission_error = self::permission_nonce_error($permission);
659
-        if ( $permission_error !== false ) {
660
-            if ( 'hide' == $show_message ) {
661
-                $permission_error = '';
662
-            }
663
-            wp_die($permission_error);
664
-        }
665
-    }
666
-
667
-    /**
668
-     * Check user permission and nonce
669
-     * @since 2.0
670
-     * @param string $permission
671
-     * @return false|string The permission message or false if allowed
672
-     */
658
+		$permission_error = self::permission_nonce_error($permission);
659
+		if ( $permission_error !== false ) {
660
+			if ( 'hide' == $show_message ) {
661
+				$permission_error = '';
662
+			}
663
+			wp_die($permission_error);
664
+		}
665
+	}
666
+
667
+	/**
668
+	 * Check user permission and nonce
669
+	 * @since 2.0
670
+	 * @param string $permission
671
+	 * @return false|string The permission message or false if allowed
672
+	 */
673 673
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
674 674
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
675 675
 			$frm_settings = self::get_settings();
@@ -677,75 +677,75 @@  discard block
 block discarded – undo
677 677
 		}
678 678
 
679 679
 		$error = false;
680
-        if ( empty($nonce_name) ) {
681
-            return $error;
682
-        }
680
+		if ( empty($nonce_name) ) {
681
+			return $error;
682
+		}
683 683
 
684
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
685
-            $frm_settings = self::get_settings();
686
-            $error = $frm_settings->admin_permission;
687
-        }
684
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
685
+			$frm_settings = self::get_settings();
686
+			$error = $frm_settings->admin_permission;
687
+		}
688 688
 
689
-        return $error;
690
-    }
689
+		return $error;
690
+	}
691 691
 
692
-    public static function checked( $values, $current ) {
692
+	public static function checked( $values, $current ) {
693 693
 		if ( self::check_selected( $values, $current ) ) {
694
-            echo ' checked="checked"';
694
+			echo ' checked="checked"';
695 695
 		}
696
-    }
696
+	}
697 697
 
698 698
 	public static function check_selected( $values, $current ) {
699
-        $values = self::recursive_function_map( $values, 'trim' );
700
-        $current = trim($current);
701
-
702
-        return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
703
-    }
704
-
705
-    /**
706
-    * Check if current field option is an "other" option
707
-    *
708
-    * @since 2.0
709
-    *
710
-    * @param string $opt_key
711
-    * @return boolean Returns true if current field option is an "Other" option
712
-    */
713
-    public static function is_other_opt( $opt_key ) {
714
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
715
-        return FrmFieldsHelper::is_other_opt( $opt_key );
716
-    }
717
-
718
-    /**
719
-    * Get value that belongs in "Other" text box
720
-    *
721
-    * @since 2.0
722
-    *
723
-    * @param string $opt_key
724
-    * @param array $field
725
-    * @return string $other_val
726
-    */
727
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
699
+		$values = self::recursive_function_map( $values, 'trim' );
700
+		$current = trim($current);
701
+
702
+		return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
703
+	}
704
+
705
+	/**
706
+	 * Check if current field option is an "other" option
707
+	 *
708
+	 * @since 2.0
709
+	 *
710
+	 * @param string $opt_key
711
+	 * @return boolean Returns true if current field option is an "Other" option
712
+	 */
713
+	public static function is_other_opt( $opt_key ) {
714
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
715
+		return FrmFieldsHelper::is_other_opt( $opt_key );
716
+	}
717
+
718
+	/**
719
+	 * Get value that belongs in "Other" text box
720
+	 *
721
+	 * @since 2.0
722
+	 *
723
+	 * @param string $opt_key
724
+	 * @param array $field
725
+	 * @return string $other_val
726
+	 */
727
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
728 728
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
729 729
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
730
-    }
731
-
732
-    /**
733
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
734
-    * Intended for front-end use
735
-    *
736
-    * @since 2.0
737
-    *
738
-    * @param array $field
739
-    * @param boolean $other_opt
740
-    * @param string $checked
741
-    * @param array $args should include opt_key and field name
742
-    * @return string $other_val
743
-    */
744
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
730
+	}
731
+
732
+	/**
733
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
734
+	 * Intended for front-end use
735
+	 *
736
+	 * @since 2.0
737
+	 *
738
+	 * @param array $field
739
+	 * @param boolean $other_opt
740
+	 * @param string $checked
741
+	 * @param array $args should include opt_key and field name
742
+	 * @return string $other_val
743
+	 */
744
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
745 745
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
746 746
 		$args['field'] = $field;
747 747
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
748
-    }
748
+	}
749 749
 
750 750
 	public static function recursive_function_map( $value, $function ) {
751 751
 		if ( is_array( $value ) ) {
@@ -775,334 +775,334 @@  discard block
 block discarded – undo
775 775
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
776 776
 	}
777 777
 
778
-    /**
779
-     * Flatten a multi-dimensional array
780
-     */
778
+	/**
779
+	 * Flatten a multi-dimensional array
780
+	 */
781 781
 	public static function array_flatten( $array, $keys = 'keep' ) {
782
-        $return = array();
783
-        foreach ( $array as $key => $value ) {
784
-            if ( is_array($value) ) {
782
+		$return = array();
783
+		foreach ( $array as $key => $value ) {
784
+			if ( is_array($value) ) {
785 785
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
786
-            } else {
786
+			} else {
787 787
 				if ( $keys == 'keep' ) {
788 788
 					$return[ $key ] = $value;
789 789
 				} else {
790 790
 					$return[] = $value;
791 791
 				}
792
-            }
793
-        }
794
-        return $return;
795
-    }
796
-
797
-    public static function esc_textarea( $text ) {
798
-        $safe_text = str_replace('&quot;', '"', $text);
799
-        $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
800
-    	return apply_filters( 'esc_textarea', $safe_text, $text );
801
-    }
802
-
803
-    /**
804
-     * Add auto paragraphs to text areas
805
-     * @since 2.0
806
-     */
792
+			}
793
+		}
794
+		return $return;
795
+	}
796
+
797
+	public static function esc_textarea( $text ) {
798
+		$safe_text = str_replace('&quot;', '"', $text);
799
+		$safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
800
+		return apply_filters( 'esc_textarea', $safe_text, $text );
801
+	}
802
+
803
+	/**
804
+	 * Add auto paragraphs to text areas
805
+	 * @since 2.0
806
+	 */
807 807
 	public static function use_wpautop( $content ) {
808
-        if ( apply_filters('frm_use_wpautop', true) ) {
809
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
810
-        }
811
-        return $content;
812
-    }
808
+		if ( apply_filters('frm_use_wpautop', true) ) {
809
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
810
+		}
811
+		return $content;
812
+	}
813 813
 
814 814
 	public static function replace_quotes( $val ) {
815
-        //Replace double quotes
815
+		//Replace double quotes
816 816
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
817
-        //Replace single quotes
818
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
819
-        return $val;
820
-    }
821
-
822
-    /**
823
-     * @since 2.0
824
-     * @return string The base Google APIS url for the current version of jQuery UI
825
-     */
826
-    public static function jquery_ui_base_url() {
827
-        $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
828
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
829
-        return $url;
830
-    }
831
-
832
-    /**
833
-     * @param string $handle
834
-     */
817
+		//Replace single quotes
818
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
819
+		return $val;
820
+	}
821
+
822
+	/**
823
+	 * @since 2.0
824
+	 * @return string The base Google APIS url for the current version of jQuery UI
825
+	 */
826
+	public static function jquery_ui_base_url() {
827
+		$url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
828
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
829
+		return $url;
830
+	}
831
+
832
+	/**
833
+	 * @param string $handle
834
+	 */
835 835
 	public static function script_version( $handle ) {
836
-        global $wp_scripts;
837
-    	if ( ! $wp_scripts ) {
838
-    	    return false;
839
-    	}
836
+		global $wp_scripts;
837
+		if ( ! $wp_scripts ) {
838
+			return false;
839
+		}
840 840
 
841
-        $ver = 0;
841
+		$ver = 0;
842 842
 
843
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
844
-            return $ver;
845
-        }
843
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
844
+			return $ver;
845
+		}
846 846
 
847
-        $query = $wp_scripts->registered[ $handle ];
848
-    	if ( is_object( $query ) ) {
849
-    	    $ver = $query->ver;
850
-    	}
847
+		$query = $wp_scripts->registered[ $handle ];
848
+		if ( is_object( $query ) ) {
849
+			$ver = $query->ver;
850
+		}
851 851
 
852
-    	return $ver;
853
-    }
852
+		return $ver;
853
+	}
854 854
 
855 855
 	public static function js_redirect( $url ) {
856 856
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
857
-    }
857
+	}
858 858
 
859 859
 	public static function get_user_id_param( $user_id ) {
860
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
861
-            return $user_id;
862
-        }
860
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
861
+			return $user_id;
862
+		}
863 863
 
864 864
 		if ( $user_id == 'current' ) {
865
-            $user_ID = get_current_user_id();
866
-            $user_id = $user_ID;
865
+			$user_ID = get_current_user_id();
866
+			$user_id = $user_ID;
867 867
 		} else {
868
-            if ( is_email($user_id) ) {
869
-                $user = get_user_by('email', $user_id);
870
-            } else {
871
-                $user = get_user_by('login', $user_id);
872
-            }
868
+			if ( is_email($user_id) ) {
869
+				$user = get_user_by('email', $user_id);
870
+			} else {
871
+				$user = get_user_by('login', $user_id);
872
+			}
873 873
 
874
-            if ( $user ) {
875
-                $user_id = $user->ID;
876
-            }
877
-            unset($user);
878
-        }
874
+			if ( $user ) {
875
+				$user_id = $user->ID;
876
+			}
877
+			unset($user);
878
+		}
879 879
 
880
-        return $user_id;
881
-    }
880
+		return $user_id;
881
+	}
882 882
 
883 883
 	public static function get_file_contents( $filename, $atts = array() ) {
884
-        if ( ! is_file($filename) ) {
885
-            return false;
886
-        }
887
-
888
-        extract($atts);
889
-        ob_start();
890
-        include($filename);
891
-        $contents = ob_get_contents();
892
-        ob_end_clean();
893
-        return $contents;
894
-    }
895
-
896
-    /**
897
-     * @param string $table_name
898
-     * @param string $column
899
-     */
900
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) {
901
-        global $wpdb;
902
-
903
-        $key = '';
904
-
905
-        if ( ! empty( $name ) ) {
906
-            $key = sanitize_key($name);
907
-        }
884
+		if ( ! is_file($filename) ) {
885
+			return false;
886
+		}
887
+
888
+		extract($atts);
889
+		ob_start();
890
+		include($filename);
891
+		$contents = ob_get_contents();
892
+		ob_end_clean();
893
+		return $contents;
894
+	}
895
+
896
+	/**
897
+	 * @param string $table_name
898
+	 * @param string $column
899
+	 */
900
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) {
901
+		global $wpdb;
902
+
903
+		$key = '';
904
+
905
+		if ( ! empty( $name ) ) {
906
+			$key = sanitize_key($name);
907
+		}
908 908
 
909 909
 		if ( empty( $key ) ) {
910
-            $max_slug_value = pow(36, $num_chars);
911
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
912
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
913
-        }
910
+			$max_slug_value = pow(36, $num_chars);
911
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
912
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
913
+		}
914 914
 
915 915
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
916
-            $key = $key .'a';
917
-        }
916
+			$key = $key .'a';
917
+		}
918 918
 
919 919
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
920 920
 
921
-        if ( $key_check || is_numeric($key_check) ) {
922
-            $suffix = 2;
921
+		if ( $key_check || is_numeric($key_check) ) {
922
+			$suffix = 2;
923 923
 			do {
924 924
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
925 925
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
926 926
 				$suffix++;
927 927
 			} while ($key_check || is_numeric($key_check));
928 928
 			$key = $alt_post_name;
929
-        }
930
-        return $key;
931
-    }
932
-
933
-    /**
934
-     * Editing a Form or Entry
935
-     * @param string $table
936
-     * @return bool|array
937
-     */
938
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
939
-        if ( ! $record ) {
940
-            return false;
941
-        }
942
-
943
-        global $frm_vars;
944
-
945
-        if ( empty($post_values) ) {
946
-            $post_values = stripslashes_deep($_POST);
947
-        }
929
+		}
930
+		return $key;
931
+	}
932
+
933
+	/**
934
+	 * Editing a Form or Entry
935
+	 * @param string $table
936
+	 * @return bool|array
937
+	 */
938
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
939
+		if ( ! $record ) {
940
+			return false;
941
+		}
942
+
943
+		global $frm_vars;
944
+
945
+		if ( empty($post_values) ) {
946
+			$post_values = stripslashes_deep($_POST);
947
+		}
948 948
 
949 949
 		$values = array( 'id' => $record->id, 'fields' => array() );
950 950
 
951 951
 		foreach ( array( 'name', 'description' ) as $var ) {
952
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
953
-            $values[ $var ] = self::get_param( $var, $default_val );
954
-            unset($var, $default_val);
955
-        }
956
-
957
-        $values['description'] = self::use_wpautop($values['description']);
958
-        $frm_settings = self::get_settings();
959
-        $is_form_builder = self::is_admin_page('formidable' );
960
-
961
-        foreach ( (array) $fields as $field ) {
962
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
963
-            if ( ! $is_form_builder ) {
964
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
965
-            }
952
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
953
+			$values[ $var ] = self::get_param( $var, $default_val );
954
+			unset($var, $default_val);
955
+		}
956
+
957
+		$values['description'] = self::use_wpautop($values['description']);
958
+		$frm_settings = self::get_settings();
959
+		$is_form_builder = self::is_admin_page('formidable' );
960
+
961
+		foreach ( (array) $fields as $field ) {
962
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
963
+			if ( ! $is_form_builder ) {
964
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
965
+			}
966 966
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
967 967
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
968
-        }
968
+		}
969 969
 
970
-        self::fill_form_opts($record, $table, $post_values, $values);
970
+		self::fill_form_opts($record, $table, $post_values, $values);
971 971
 
972
-        if ( $table == 'entries' ) {
973
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
974
-        } else if ( $table == 'forms' ) {
975
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
976
-        }
972
+		if ( $table == 'entries' ) {
973
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
974
+		} else if ( $table == 'forms' ) {
975
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
976
+		}
977 977
 
978
-        return $values;
979
-    }
978
+		return $values;
979
+	}
980 980
 
981 981
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
982
-        $post_values = $args['post_values'];
983
-
984
-        if ( $args['default'] ) {
985
-            $meta_value = $field->default_value;
986
-        } else {
987
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
988
-                if ( ! isset($field->field_options['custom_field']) ) {
989
-                    $field->field_options['custom_field'] = '';
990
-                }
982
+		$post_values = $args['post_values'];
983
+
984
+		if ( $args['default'] ) {
985
+			$meta_value = $field->default_value;
986
+		} else {
987
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
988
+				if ( ! isset($field->field_options['custom_field']) ) {
989
+					$field->field_options['custom_field'] = '';
990
+				}
991 991
 				$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 ) );
992
-            } else {
992
+			} else {
993 993
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
994
-            }
995
-        }
996
-
997
-        $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
998
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
999
-
1000
-        $field_array = array(
1001
-            'id'            => $field->id,
1002
-            'value'         => $new_value,
1003
-            'default_value' => $field->default_value,
1004
-            'name'          => $field->name,
1005
-            'description'   => $field->description,
1006
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1007
-            'options'       => $field->options,
1008
-            'required'      => $field->required,
1009
-            'field_key'     => $field->field_key,
1010
-            'field_order'   => $field->field_order,
1011
-            'form_id'       => $field->form_id,
994
+			}
995
+		}
996
+
997
+		$field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
998
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
999
+
1000
+		$field_array = array(
1001
+			'id'            => $field->id,
1002
+			'value'         => $new_value,
1003
+			'default_value' => $field->default_value,
1004
+			'name'          => $field->name,
1005
+			'description'   => $field->description,
1006
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1007
+			'options'       => $field->options,
1008
+			'required'      => $field->required,
1009
+			'field_key'     => $field->field_key,
1010
+			'field_order'   => $field->field_order,
1011
+			'form_id'       => $field->form_id,
1012 1012
 			'parent_form_id' => $args['parent_form_id'],
1013
-        );
1013
+		);
1014 1014
 
1015
-        $args['field_type'] = $field_type;
1016
-        self::fill_field_opts($field, $field_array, $args);
1015
+		$args['field_type'] = $field_type;
1016
+		self::fill_field_opts($field, $field_array, $args);
1017 1017
 
1018
-        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1018
+		$field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1019 1019
 
1020
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1021
-            $field_array['unique_msg'] = '';
1022
-        }
1020
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1021
+			$field_array['unique_msg'] = '';
1022
+		}
1023 1023
 
1024
-        $field_array = array_merge( $field->field_options, $field_array );
1024
+		$field_array = array_merge( $field->field_options, $field_array );
1025 1025
 
1026
-        $values['fields'][ $field->id ] = $field_array;
1027
-    }
1026
+		$values['fields'][ $field->id ] = $field_array;
1027
+	}
1028 1028
 
1029 1029
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1030
-        $post_values = $args['post_values'];
1031
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1032
-
1033
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1034
-            $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 );
1035
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1036
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1037
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1038
-                if ( $args['field_type'] == 'captcha' ) {
1039
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1040
-                } else {
1041
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1042
-                }
1043
-            }
1044
-        }
1045
-
1046
-        if ( $field_array['custom_html'] == '' ) {
1047
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1048
-        }
1049
-    }
1050
-
1051
-    /**
1052
-     * @param string $table
1053
-     */
1030
+		$post_values = $args['post_values'];
1031
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1032
+
1033
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1034
+			$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 );
1035
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1036
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1037
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1038
+				if ( $args['field_type'] == 'captcha' ) {
1039
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1040
+				} else {
1041
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1042
+				}
1043
+			}
1044
+		}
1045
+
1046
+		if ( $field_array['custom_html'] == '' ) {
1047
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1048
+		}
1049
+	}
1050
+
1051
+	/**
1052
+	 * @param string $table
1053
+	 */
1054 1054
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1055
-        if ( $table == 'entries' ) {
1056
-            $form = $record->form_id;
1055
+		if ( $table == 'entries' ) {
1056
+			$form = $record->form_id;
1057 1057
 			FrmForm::maybe_get_form( $form );
1058
-        } else {
1059
-            $form = $record;
1060
-        }
1058
+		} else {
1059
+			$form = $record;
1060
+		}
1061 1061
 
1062
-        if ( ! $form ) {
1063
-            return;
1064
-        }
1062
+		if ( ! $form ) {
1063
+			return;
1064
+		}
1065 1065
 
1066
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1066
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1067 1067
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1068 1068
 
1069
-        if ( ! is_array($form->options) ) {
1070
-            return;
1071
-        }
1069
+		if ( ! is_array($form->options) ) {
1070
+			return;
1071
+		}
1072 1072
 
1073
-        foreach ( $form->options as $opt => $value ) {
1074
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1075
-        }
1073
+		foreach ( $form->options as $opt => $value ) {
1074
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1075
+		}
1076 1076
 
1077
-        self::fill_form_defaults($post_values, $values);
1078
-    }
1077
+		self::fill_form_defaults($post_values, $values);
1078
+	}
1079 1079
 
1080
-    /**
1081
-     * Set to POST value or default
1082
-     */
1080
+	/**
1081
+	 * Set to POST value or default
1082
+	 */
1083 1083
 	private static function fill_form_defaults( $post_values, array &$values ) {
1084
-        $form_defaults = FrmFormsHelper::get_default_opts();
1084
+		$form_defaults = FrmFormsHelper::get_default_opts();
1085 1085
 
1086
-        foreach ( $form_defaults as $opt => $default ) {
1087
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1086
+		foreach ( $form_defaults as $opt => $default ) {
1087
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1088 1088
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1089
-            }
1089
+			}
1090 1090
 
1091
-            unset($opt, $defaut);
1092
-        }
1091
+			unset($opt, $defaut);
1092
+		}
1093 1093
 
1094
-        if ( ! isset($values['custom_style']) ) {
1095
-            $frm_settings = self::get_settings();
1094
+		if ( ! isset($values['custom_style']) ) {
1095
+			$frm_settings = self::get_settings();
1096 1096
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1097
-        }
1097
+		}
1098 1098
 
1099 1099
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1100
-            if ( ! isset( $values[ $h .'_html' ] ) ) {
1101
-                $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1102
-            }
1103
-            unset($h);
1104
-        }
1105
-    }
1100
+			if ( ! isset( $values[ $h .'_html' ] ) ) {
1101
+				$values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1102
+			}
1103
+			unset($h);
1104
+		}
1105
+	}
1106 1106
 
1107 1107
 	public static function get_meta_value( $field_id, $entry ) {
1108 1108
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1110,69 +1110,69 @@  discard block
 block discarded – undo
1110 1110
 	}
1111 1111
 
1112 1112
 	public static function insert_opt_html( $args ) {
1113
-        $class = '';
1114
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1115
-            $class .= 'show_frm_not_email_to';
1116
-        }
1117
-    ?>
1113
+		$class = '';
1114
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1115
+			$class .= 'show_frm_not_email_to';
1116
+		}
1117
+	?>
1118 1118
 <li>
1119 1119
     <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>
1120 1120
     <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>
1121 1121
     <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>
1122 1122
 </li>
1123 1123
     <?php
1124
-    }
1124
+	}
1125 1125
 
1126
-    public static function get_us_states() {
1127
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1128
-        return FrmFieldsHelper::get_us_states();
1129
-    }
1126
+	public static function get_us_states() {
1127
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1128
+		return FrmFieldsHelper::get_us_states();
1129
+	}
1130 1130
 
1131
-    public static function get_countries() {
1132
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1133
-        return FrmFieldsHelper::get_countries();
1134
-    }
1131
+	public static function get_countries() {
1132
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1133
+		return FrmFieldsHelper::get_countries();
1134
+	}
1135 1135
 
1136 1136
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1137
-        if ( is_array( $str ) ) {
1138
-            return;
1137
+		if ( is_array( $str ) ) {
1138
+			return;
1139 1139
 		}
1140 1140
 
1141
-        $length = (int) $length;
1141
+		$length = (int) $length;
1142 1142
 		$str = wp_strip_all_tags( $str );
1143 1143
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1144 1144
 
1145 1145
 		if ( $length == 0 ) {
1146
-            return '';
1147
-        } else if ( $length <= 10 ) {
1146
+			return '';
1147
+		} else if ( $length <= 10 ) {
1148 1148
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1149
-            return $sub . (($length < $original_len) ? $continue : '');
1150
-        }
1149
+			return $sub . (($length < $original_len) ? $continue : '');
1150
+		}
1151 1151
 
1152
-        $sub = '';
1153
-        $len = 0;
1152
+		$sub = '';
1153
+		$len = 0;
1154 1154
 
1155 1155
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1156 1156
 
1157 1157
 		foreach ( $words as $word ) {
1158
-            $part = (($sub != '') ? ' ' : '') . $word;
1158
+			$part = (($sub != '') ? ' ' : '') . $word;
1159 1159
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1160
-            if ( $total_len > $length && str_word_count($sub) ) {
1161
-                break;
1162
-            }
1160
+			if ( $total_len > $length && str_word_count($sub) ) {
1161
+				break;
1162
+			}
1163 1163
 
1164
-            $sub .= $part;
1164
+			$sub .= $part;
1165 1165
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1166 1166
 
1167
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1168
-                break;
1169
-            }
1167
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1168
+				break;
1169
+			}
1170 1170
 
1171
-            unset($total_len, $word);
1172
-        }
1171
+			unset($total_len, $word);
1172
+		}
1173 1173
 
1174
-        return $sub . (($len < $original_len) ? $continue : '');
1175
-    }
1174
+		return $sub . (($len < $original_len) ? $continue : '');
1175
+	}
1176 1176
 
1177 1177
 	public static function mb_function( $function_names, $args ) {
1178 1178
 		$mb_function_name = $function_names[0];
@@ -1184,18 +1184,18 @@  discard block
 block discarded – undo
1184 1184
 	}
1185 1185
 
1186 1186
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1187
-        if ( empty($date) ) {
1188
-            return $date;
1189
-        }
1187
+		if ( empty($date) ) {
1188
+			return $date;
1189
+		}
1190 1190
 
1191
-        if ( empty($date_format) ) {
1192
-            $date_format = get_option('date_format');
1193
-        }
1191
+		if ( empty($date_format) ) {
1192
+			$date_format = get_option('date_format');
1193
+		}
1194 1194
 
1195
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1196
-            $frmpro_settings = new FrmProSettings();
1197
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1198
-        }
1195
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1196
+			$frmpro_settings = new FrmProSettings();
1197
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1198
+		}
1199 1199
 
1200 1200
 		$formatted = self::get_localized_date( $date_format, $date );
1201 1201
 
@@ -1204,8 +1204,8 @@  discard block
 block discarded – undo
1204 1204
 			$formatted .= self::add_time_to_date( $time_format, $date );
1205 1205
 		}
1206 1206
 
1207
-        return $formatted;
1208
-    }
1207
+		return $formatted;
1208
+	}
1209 1209
 
1210 1210
 	private static function add_time_to_date( $time_format, $date ) {
1211 1211
 		if ( empty( $time_format ) ) {
@@ -1229,117 +1229,117 @@  discard block
 block discarded – undo
1229 1229
 		return date_i18n( $date_format, strtotime( $date ) );
1230 1230
 	}
1231 1231
 
1232
-    /**
1233
-     * @return string The time ago in words
1234
-     */
1235
-    public static function human_time_diff( $from, $to = '' ) {
1236
-    	if ( empty($to) ) {
1237
-    	    		$to = time();
1238
-    	}
1239
-
1240
-    	// Array of time period chunks
1241
-    	$chunks = array(
1242
-    		array( 60 * 60 * 24 * 365, __( 'year', 'formidable' ), __( 'years', 'formidable' ) ),
1243
-    		array( 60 * 60 * 24 * 30, __( 'month', 'formidable' ), __( 'months', 'formidable' ) ),
1244
-    		array( 60 * 60 * 24 * 7, __( 'week', 'formidable' ), __( 'weeks', 'formidable' ) ),
1245
-    		array( 60 * 60 * 24, __( 'day', 'formidable' ), __( 'days', 'formidable' ) ),
1246
-    		array( 60 * 60, __( 'hour', 'formidable' ), __( 'hours', 'formidable' ) ),
1247
-    		array( 60, __( 'minute', 'formidable' ), __( 'minutes', 'formidable' ) ),
1248
-    		array( 1, __( 'second', 'formidable' ), __( 'seconds', 'formidable' ) ),
1249
-    	);
1250
-
1251
-    	// Difference in seconds
1252
-    	$diff = (int) ($to - $from);
1253
-
1254
-    	// Something went wrong with date calculation and we ended up with a negative date.
1232
+	/**
1233
+	 * @return string The time ago in words
1234
+	 */
1235
+	public static function human_time_diff( $from, $to = '' ) {
1236
+		if ( empty($to) ) {
1237
+					$to = time();
1238
+		}
1239
+
1240
+		// Array of time period chunks
1241
+		$chunks = array(
1242
+			array( 60 * 60 * 24 * 365, __( 'year', 'formidable' ), __( 'years', 'formidable' ) ),
1243
+			array( 60 * 60 * 24 * 30, __( 'month', 'formidable' ), __( 'months', 'formidable' ) ),
1244
+			array( 60 * 60 * 24 * 7, __( 'week', 'formidable' ), __( 'weeks', 'formidable' ) ),
1245
+			array( 60 * 60 * 24, __( 'day', 'formidable' ), __( 'days', 'formidable' ) ),
1246
+			array( 60 * 60, __( 'hour', 'formidable' ), __( 'hours', 'formidable' ) ),
1247
+			array( 60, __( 'minute', 'formidable' ), __( 'minutes', 'formidable' ) ),
1248
+			array( 1, __( 'second', 'formidable' ), __( 'seconds', 'formidable' ) ),
1249
+		);
1250
+
1251
+		// Difference in seconds
1252
+		$diff = (int) ($to - $from);
1253
+
1254
+		// Something went wrong with date calculation and we ended up with a negative date.
1255 1255
 		if ( $diff < 1 ) {
1256 1256
 			return '0 ' . __( 'seconds', 'formidable' );
1257
-    	}
1257
+		}
1258 1258
 
1259
-    	/**
1260
-    	 * We only want to output one chunks of time here, eg:
1261
-    	 * x years
1262
-    	 * xx months
1263
-    	 * so there's only one bit of calculation below:
1264
-    	 */
1259
+		/**
1260
+		 * We only want to output one chunks of time here, eg:
1261
+		 * x years
1262
+		 * xx months
1263
+		 * so there's only one bit of calculation below:
1264
+		 */
1265 1265
 
1266
-        $count = 0;
1266
+		$count = 0;
1267 1267
 
1268
-    	//Step one: the first chunk
1268
+		//Step one: the first chunk
1269 1269
 		for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) {
1270
-    		$seconds = $chunks[ $i ][0];
1271
-
1272
-    		// Finding the biggest chunk (if the chunk fits, break)
1273
-    		if ( ( $count = floor($diff / $seconds) ) != 0 ) {
1274
-    		    			break;
1275
-    		}
1276
-    	}
1277
-
1278
-    	// Set output var
1279
-    	$output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2];
1280
-
1281
-    	if ( ! (int) trim( $output ) ) {
1282
-    		$output = '0 ' . __( 'seconds', 'formidable' );
1283
-        }
1284
-
1285
-    	return $output;
1286
-    }
1287
-
1288
-    /**
1289
-     * Added for < WP 4.0 compatability
1290
-     *
1291
-     * @since 1.07.10
1292
-     *
1293
-     * @param string $term The value to escape
1294
-     * @return string The escaped value
1295
-     */
1270
+			$seconds = $chunks[ $i ][0];
1271
+
1272
+			// Finding the biggest chunk (if the chunk fits, break)
1273
+			if ( ( $count = floor($diff / $seconds) ) != 0 ) {
1274
+							break;
1275
+			}
1276
+		}
1277
+
1278
+		// Set output var
1279
+		$output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2];
1280
+
1281
+		if ( ! (int) trim( $output ) ) {
1282
+			$output = '0 ' . __( 'seconds', 'formidable' );
1283
+		}
1284
+
1285
+		return $output;
1286
+	}
1287
+
1288
+	/**
1289
+	 * Added for < WP 4.0 compatability
1290
+	 *
1291
+	 * @since 1.07.10
1292
+	 *
1293
+	 * @param string $term The value to escape
1294
+	 * @return string The escaped value
1295
+	 */
1296 1296
 	public static function esc_like( $term ) {
1297
-        global $wpdb;
1298
-        if ( method_exists($wpdb, 'esc_like') ) {
1297
+		global $wpdb;
1298
+		if ( method_exists($wpdb, 'esc_like') ) {
1299 1299
 			// WP 4.0
1300
-            $term = $wpdb->esc_like( $term );
1301
-        } else {
1302
-            $term = like_escape( $term );
1303
-        }
1300
+			$term = $wpdb->esc_like( $term );
1301
+		} else {
1302
+			$term = like_escape( $term );
1303
+		}
1304 1304
 
1305
-        return $term;
1306
-    }
1305
+		return $term;
1306
+	}
1307 1307
 
1308
-    /**
1309
-     * @param string $order_query
1310
-     */
1308
+	/**
1309
+	 * @param string $order_query
1310
+	 */
1311 1311
 	public static function esc_order( $order_query ) {
1312
-        if ( empty($order_query) ) {
1313
-            return '';
1314
-        }
1315
-
1316
-        // remove ORDER BY before santizing
1317
-        $order_query = strtolower($order_query);
1318
-        if ( strpos($order_query, 'order by') !== false ) {
1319
-            $order_query = str_replace('order by', '', $order_query);
1320
-        }
1321
-
1322
-        $order_query = explode(' ', trim($order_query));
1323
-
1324
-        $order_fields = array(
1325
-            'id', 'form_key', 'name', 'description',
1326
-            'parent_form_id', 'logged_in', 'is_template',
1327
-            'default_template', 'status', 'created_at',
1328
-        );
1329
-
1330
-        $order = trim(trim(reset($order_query), ','));
1331
-        if ( ! in_array($order, $order_fields) ) {
1332
-            return '';
1333
-        }
1334
-
1335
-        $order_by = '';
1336
-        if ( count($order_query) > 1 ) {
1312
+		if ( empty($order_query) ) {
1313
+			return '';
1314
+		}
1315
+
1316
+		// remove ORDER BY before santizing
1317
+		$order_query = strtolower($order_query);
1318
+		if ( strpos($order_query, 'order by') !== false ) {
1319
+			$order_query = str_replace('order by', '', $order_query);
1320
+		}
1321
+
1322
+		$order_query = explode(' ', trim($order_query));
1323
+
1324
+		$order_fields = array(
1325
+			'id', 'form_key', 'name', 'description',
1326
+			'parent_form_id', 'logged_in', 'is_template',
1327
+			'default_template', 'status', 'created_at',
1328
+		);
1329
+
1330
+		$order = trim(trim(reset($order_query), ','));
1331
+		if ( ! in_array($order, $order_fields) ) {
1332
+			return '';
1333
+		}
1334
+
1335
+		$order_by = '';
1336
+		if ( count($order_query) > 1 ) {
1337 1337
 			$order_by = end( $order_query );
1338 1338
 			self::esc_order_by( $order_by );
1339
-        }
1339
+		}
1340 1340
 
1341
-        return ' ORDER BY '. $order . ' '. $order_by;
1342
-    }
1341
+		return ' ORDER BY '. $order . ' '. $order_by;
1342
+	}
1343 1343
 
1344 1344
 	/**
1345 1345
 	 * Make sure this is ordering by either ASC or DESC
@@ -1351,183 +1351,183 @@  discard block
 block discarded – undo
1351 1351
 		}
1352 1352
 	}
1353 1353
 
1354
-    /**
1355
-     * @param string $limit
1356
-     */
1354
+	/**
1355
+	 * @param string $limit
1356
+	 */
1357 1357
 	public static function esc_limit( $limit ) {
1358
-        if ( empty($limit) ) {
1359
-            return '';
1360
-        }
1361
-
1362
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1363
-        if ( is_numeric($limit) ) {
1364
-            return ' LIMIT '. $limit;
1365
-        }
1366
-
1367
-        $limit = explode(',', trim($limit));
1368
-        foreach ( $limit as $k => $l ) {
1369
-            if ( is_numeric( $l ) ) {
1370
-                $limit[ $k ] = $l;
1371
-            }
1372
-        }
1373
-
1374
-        $limit = implode(',', $limit);
1375
-        return ' LIMIT '. $limit;
1376
-    }
1377
-
1378
-    /**
1379
-     * Get an array of values ready to go through $wpdb->prepare
1380
-     * @since 2.0
1381
-     */
1382
-    public static function prepare_array_values( $array, $type = '%s' ) {
1383
-        $placeholders = array_fill(0, count($array), $type);
1384
-        return implode(', ', $placeholders);
1385
-    }
1386
-
1387
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1388
-        if ( empty($where) ) {
1389
-            return '';
1390
-        }
1358
+		if ( empty($limit) ) {
1359
+			return '';
1360
+		}
1361
+
1362
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1363
+		if ( is_numeric($limit) ) {
1364
+			return ' LIMIT '. $limit;
1365
+		}
1366
+
1367
+		$limit = explode(',', trim($limit));
1368
+		foreach ( $limit as $k => $l ) {
1369
+			if ( is_numeric( $l ) ) {
1370
+				$limit[ $k ] = $l;
1371
+			}
1372
+		}
1373
+
1374
+		$limit = implode(',', $limit);
1375
+		return ' LIMIT '. $limit;
1376
+	}
1377
+
1378
+	/**
1379
+	 * Get an array of values ready to go through $wpdb->prepare
1380
+	 * @since 2.0
1381
+	 */
1382
+	public static function prepare_array_values( $array, $type = '%s' ) {
1383
+		$placeholders = array_fill(0, count($array), $type);
1384
+		return implode(', ', $placeholders);
1385
+	}
1386
+
1387
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1388
+		if ( empty($where) ) {
1389
+			return '';
1390
+		}
1391 1391
 
1392 1392
 		if ( is_array( $where ) ) {
1393
-            global $wpdb;
1394
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1393
+			global $wpdb;
1394
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1395 1395
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1396 1396
 		} else {
1397
-            $where = $starts_with . $where;
1398
-        }
1397
+			$where = $starts_with . $where;
1398
+		}
1399 1399
 
1400
-        return $where;
1401
-    }
1400
+		return $where;
1401
+	}
1402 1402
 
1403
-    // Pagination Methods
1403
+	// Pagination Methods
1404 1404
 
1405
-    /**
1406
-     * @param integer $current_p
1407
-     */
1405
+	/**
1406
+	 * @param integer $current_p
1407
+	 */
1408 1408
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1409 1409
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1410 1410
 	}
1411 1411
 
1412
-    /**
1413
-     * @param integer $current_p
1414
-     */
1415
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1416
-        if ( $current_p == 1 ) {
1417
-            return 1;
1418
-        } else {
1419
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1420
-        }
1421
-    }
1422
-
1423
-    /**
1424
-     * @param string $table_name
1425
-     */
1426
-    public static function &getRecordCount( $where = '', $table_name ) {
1427
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1428
-        $count = FrmDb::get_count( $table_name, $where );
1429
-        return $count;
1430
-    }
1431
-
1432
-    public static function get_referer_info() {
1433
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1434
-        return self::get_server_value('HTTP_REFERER');
1435
-    }
1412
+	/**
1413
+	 * @param integer $current_p
1414
+	 */
1415
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1416
+		if ( $current_p == 1 ) {
1417
+			return 1;
1418
+		} else {
1419
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1420
+		}
1421
+	}
1422
+
1423
+	/**
1424
+	 * @param string $table_name
1425
+	 */
1426
+	public static function &getRecordCount( $where = '', $table_name ) {
1427
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1428
+		$count = FrmDb::get_count( $table_name, $where );
1429
+		return $count;
1430
+	}
1431
+
1432
+	public static function get_referer_info() {
1433
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1434
+		return self::get_server_value('HTTP_REFERER');
1435
+	}
1436 1436
 
1437 1437
 	/**
1438 1438
 	 * @return array
1439 1439
 	 */
1440 1440
 	public static function json_to_array( $json_vars ) {
1441
-        $vars = array();
1442
-        foreach ( $json_vars as $jv ) {
1443
-            $jv_name = explode('[', $jv['name']);
1444
-            $last = count($jv_name) - 1;
1445
-            foreach ( $jv_name as $p => $n ) {
1446
-                $name = trim($n, ']');
1447
-                if ( ! isset($l1) ) {
1448
-                    $l1 = $name;
1449
-                }
1450
-
1451
-                if ( ! isset($l2) ) {
1452
-                    $l2 = $name;
1453
-                }
1454
-
1455
-                if ( ! isset($l3) ) {
1456
-                    $l3 = $name;
1457
-                }
1458
-
1459
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1460
-
1461
-                switch ( $p ) {
1462
-                    case 0:
1463
-                        $l1 = $name;
1464
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1465
-                    break;
1466
-
1467
-                    case 1:
1468
-                        $l2 = $name;
1469
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1470
-                    break;
1471
-
1472
-                    case 2:
1473
-                        $l3 = $name;
1474
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1475
-                    break;
1476
-
1477
-                    case 3:
1478
-                        $l4 = $name;
1479
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1480
-                    break;
1481
-                }
1482
-
1483
-                unset($this_val, $n);
1484
-            }
1485
-
1486
-            unset($last, $jv);
1487
-        }
1488
-
1489
-        return $vars;
1490
-    }
1491
-
1492
-    /**
1493
-     * @param string $name
1494
-     * @param string $l1
1495
-     */
1496
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1497
-        if ( $name == '' ) {
1498
-            $vars[] = $val;
1499
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1500
-            $vars[ $l1 ] = $val;
1501
-        }
1502
-    }
1441
+		$vars = array();
1442
+		foreach ( $json_vars as $jv ) {
1443
+			$jv_name = explode('[', $jv['name']);
1444
+			$last = count($jv_name) - 1;
1445
+			foreach ( $jv_name as $p => $n ) {
1446
+				$name = trim($n, ']');
1447
+				if ( ! isset($l1) ) {
1448
+					$l1 = $name;
1449
+				}
1450
+
1451
+				if ( ! isset($l2) ) {
1452
+					$l2 = $name;
1453
+				}
1454
+
1455
+				if ( ! isset($l3) ) {
1456
+					$l3 = $name;
1457
+				}
1458
+
1459
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1460
+
1461
+				switch ( $p ) {
1462
+					case 0:
1463
+						$l1 = $name;
1464
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1465
+					break;
1466
+
1467
+					case 1:
1468
+						$l2 = $name;
1469
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1470
+					break;
1471
+
1472
+					case 2:
1473
+						$l3 = $name;
1474
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1475
+					break;
1476
+
1477
+					case 3:
1478
+						$l4 = $name;
1479
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1480
+					break;
1481
+				}
1482
+
1483
+				unset($this_val, $n);
1484
+			}
1485
+
1486
+			unset($last, $jv);
1487
+		}
1488
+
1489
+		return $vars;
1490
+	}
1491
+
1492
+	/**
1493
+	 * @param string $name
1494
+	 * @param string $l1
1495
+	 */
1496
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1497
+		if ( $name == '' ) {
1498
+			$vars[] = $val;
1499
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1500
+			$vars[ $l1 ] = $val;
1501
+		}
1502
+	}
1503 1503
 
1504 1504
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1505
-        $tooltips = array(
1506
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1507
-            'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1508
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1509
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1510
-            'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1511
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1512
-            'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1513
-        );
1514
-
1515
-        if ( ! isset( $tooltips[ $name ] ) ) {
1516
-            return;
1517
-        }
1518
-
1519
-        if ( 'open' == $class ) {
1520
-            echo ' frm_help"';
1521
-        } else {
1522
-            echo ' class="frm_help"';
1523
-        }
1524
-
1525
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1526
-
1527
-        if ( 'open' != $class ) {
1528
-            echo '"';
1529
-        }
1530
-    }
1505
+		$tooltips = array(
1506
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1507
+			'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1508
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1509
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1510
+			'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1511
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1512
+			'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1513
+		);
1514
+
1515
+		if ( ! isset( $tooltips[ $name ] ) ) {
1516
+			return;
1517
+		}
1518
+
1519
+		if ( 'open' == $class ) {
1520
+			echo ' frm_help"';
1521
+		} else {
1522
+			echo ' class="frm_help"';
1523
+		}
1524
+
1525
+		echo ' title="'. esc_attr( $tooltips[ $name ] );
1526
+
1527
+		if ( 'open' != $class ) {
1528
+			echo '"';
1529
+		}
1530
+	}
1531 1531
 
1532 1532
 	/**
1533 1533
 	 * Add the current_page class to that page in the form nav
@@ -1543,35 +1543,35 @@  discard block
 block discarded – undo
1543 1543
 		}
1544 1544
 	}
1545 1545
 
1546
-    /**
1547
-     * Prepare and json_encode post content
1548
-     *
1549
-     * @since 2.0
1550
-     *
1551
-     * @param array $post_content
1552
-     * @return string $post_content ( json encoded array )
1553
-     */
1554
-    public static function prepare_and_encode( $post_content ) {
1555
-        //Loop through array to strip slashes and add only the needed ones
1546
+	/**
1547
+	 * Prepare and json_encode post content
1548
+	 *
1549
+	 * @since 2.0
1550
+	 *
1551
+	 * @param array $post_content
1552
+	 * @return string $post_content ( json encoded array )
1553
+	 */
1554
+	public static function prepare_and_encode( $post_content ) {
1555
+		//Loop through array to strip slashes and add only the needed ones
1556 1556
 		foreach ( $post_content as $key => $val ) {
1557 1557
 			// Replace problematic characters (like &quot;)
1558 1558
 			$val = str_replace( '&quot;', '"', $val );
1559 1559
 
1560 1560
 			self::prepare_action_slashes( $val, $key, $post_content );
1561
-            unset( $key, $val );
1562
-        }
1561
+			unset( $key, $val );
1562
+		}
1563 1563
 
1564
-        // json_encode the array
1565
-        $post_content = json_encode( $post_content );
1564
+		// json_encode the array
1565
+		$post_content = json_encode( $post_content );
1566 1566
 
1567
-	    // add extra slashes for \r\n since WP strips them
1567
+		// add extra slashes for \r\n since WP strips them
1568 1568
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1569 1569
 
1570
-        // allow for &quot
1571
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1570
+		// allow for &quot
1571
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1572 1572
 
1573
-        return $post_content;
1574
-    }
1573
+		return $post_content;
1574
+	}
1575 1575
 
1576 1576
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1577 1577
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1639,64 +1639,64 @@  discard block
 block discarded – undo
1639 1639
 	}
1640 1640
 
1641 1641
 	public static function maybe_json_decode( $string ) {
1642
-        if ( is_array($string) ) {
1643
-            return $string;
1644
-        }
1642
+		if ( is_array($string) ) {
1643
+			return $string;
1644
+		}
1645 1645
 
1646
-        $new_string = json_decode($string, true);
1647
-        if ( function_exists('json_last_error') ) {
1646
+		$new_string = json_decode($string, true);
1647
+		if ( function_exists('json_last_error') ) {
1648 1648
 			// php 5.3+
1649
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1650
-                $string = $new_string;
1651
-            }
1652
-        } else if ( isset($new_string) ) {
1649
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1650
+				$string = $new_string;
1651
+			}
1652
+		} else if ( isset($new_string) ) {
1653 1653
 			// php < 5.3 fallback
1654
-            $string = $new_string;
1655
-        }
1656
-        return $string;
1657
-    }
1658
-
1659
-    /**
1660
-     * @since 1.07.10
1661
-     *
1662
-     * @param string $post_type The name of the post type that may need to be highlighted
1663
-     * @return echo The javascript to open and highlight the Formidable menu
1664
-     */
1654
+			$string = $new_string;
1655
+		}
1656
+		return $string;
1657
+	}
1658
+
1659
+	/**
1660
+	 * @since 1.07.10
1661
+	 *
1662
+	 * @param string $post_type The name of the post type that may need to be highlighted
1663
+	 * @return echo The javascript to open and highlight the Formidable menu
1664
+	 */
1665 1665
 	public static function maybe_highlight_menu( $post_type ) {
1666
-        global $post, $pagenow;
1666
+		global $post, $pagenow;
1667 1667
 
1668
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1669
-            return;
1670
-        }
1668
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1669
+			return;
1670
+		}
1671 1671
 
1672
-        if ( is_object($post) && $post->post_type != $post_type ) {
1673
-            return;
1674
-        }
1672
+		if ( is_object($post) && $post->post_type != $post_type ) {
1673
+			return;
1674
+		}
1675 1675
 
1676
-        self::load_admin_wide_js();
1677
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1678
-    }
1676
+		self::load_admin_wide_js();
1677
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1678
+	}
1679 1679
 
1680
-    /**
1681
-     * Load the JS file on non-Formidable pages in the admin area
1682
-     * @since 2.0
1683
-     */
1680
+	/**
1681
+	 * Load the JS file on non-Formidable pages in the admin area
1682
+	 * @since 2.0
1683
+	 */
1684 1684
 	public static function load_admin_wide_js( $load = true ) {
1685
-        $version = FrmAppHelper::plugin_version();
1685
+		$version = FrmAppHelper::plugin_version();
1686 1686
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1687 1687
 
1688
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1688
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1689 1689
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1690
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1690
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1691 1691
 			'url'          => FrmAppHelper::plugin_url(),
1692 1692
 			'loading'      => __( 'Loading&hellip;' ),
1693 1693
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1694
-        ) );
1694
+		) );
1695 1695
 
1696 1696
 		if ( $load ) {
1697 1697
 			wp_enqueue_script( 'formidable_admin_global' );
1698 1698
 		}
1699
-    }
1699
+	}
1700 1700
 
1701 1701
 	/**
1702 1702
 	 * @since 2.0.9
@@ -1705,9 +1705,9 @@  discard block
 block discarded – undo
1705 1705
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1706 1706
 	}
1707 1707
 
1708
-    /**
1709
-     * @param string $location
1710
-     */
1708
+	/**
1709
+	 * @param string $location
1710
+	 */
1711 1711
 	public static function localize_script( $location ) {
1712 1712
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1713 1713
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1757,81 +1757,81 @@  discard block
 block discarded – undo
1757 1757
 		}
1758 1758
 	}
1759 1759
 
1760
-    /**
1761
-     * @since 1.07.10
1762
-     *
1763
-     * @param float $min_version The version the add-on requires
1764
-     * @return echo The message on the plugins listing page
1765
-     */
1760
+	/**
1761
+	 * @since 1.07.10
1762
+	 *
1763
+	 * @param float $min_version The version the add-on requires
1764
+	 * @return echo The message on the plugins listing page
1765
+	 */
1766 1766
 	public static function min_version_notice( $min_version ) {
1767
-        $frm_version = self::plugin_version();
1767
+		$frm_version = self::plugin_version();
1768 1768
 
1769
-        // check if Formidable meets minimum requirements
1770
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1771
-            return;
1772
-        }
1769
+		// check if Formidable meets minimum requirements
1770
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1771
+			return;
1772
+		}
1773 1773
 
1774
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1774
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1775 1775
 		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">' .
1776
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1777
-        '</div></td></tr>';
1778
-    }
1779
-
1780
-    public static function locales( $type = 'date' ) {
1781
-        $locales = array(
1782
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1783
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1784
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1785
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1786
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1787
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1788
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1789
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1790
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1791
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1792
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1793
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1794
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1795
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1796
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1797
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1798
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1799
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1800
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1801
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1802
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1803
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1804
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1805
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1806
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1807
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1808
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1809
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1810
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1811
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1812
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1813
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1814
-        );
1815
-
1816
-        if ( $type == 'captcha' ) {
1817
-            // remove the languages unavailable for the captcha
1818
-            $unset = array(
1819
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1820
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1821
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1822
-            );
1823
-        } else {
1824
-            // remove the languages unavailable for the datepicker
1825
-            $unset = array(
1826
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1827
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1828
-                'es-419', 'tr',
1829
-            );
1830
-        }
1831
-
1832
-        $locales = array_diff_key($locales, array_flip($unset));
1833
-        $locales = apply_filters('frm_locales', $locales);
1834
-
1835
-        return $locales;
1836
-    }
1776
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1777
+		'</div></td></tr>';
1778
+	}
1779
+
1780
+	public static function locales( $type = 'date' ) {
1781
+		$locales = array(
1782
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1783
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1784
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1785
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1786
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1787
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1788
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1789
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1790
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1791
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1792
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1793
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1794
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1795
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1796
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1797
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1798
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1799
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1800
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1801
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1802
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1803
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1804
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1805
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1806
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1807
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1808
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1809
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1810
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1811
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1812
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1813
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1814
+		);
1815
+
1816
+		if ( $type == 'captcha' ) {
1817
+			// remove the languages unavailable for the captcha
1818
+			$unset = array(
1819
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1820
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1821
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1822
+			);
1823
+		} else {
1824
+			// remove the languages unavailable for the datepicker
1825
+			$unset = array(
1826
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1827
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1828
+				'es-419', 'tr',
1829
+			);
1830
+		}
1831
+
1832
+		$locales = array_diff_key($locales, array_flip($unset));
1833
+		$locales = apply_filters('frm_locales', $locales);
1834
+
1835
+		return $locales;
1836
+	}
1837 1837
 }
Please login to merge, or discard this patch.
classes/models/FrmEntryMeta.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -61,6 +61,9 @@  discard block
 block discarded – undo
61 61
         return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62 62
     }
63 63
 
64
+	/**
65
+	 * @param integer $entry_id
66
+	 */
64 67
 	public static function update_entry_metas( $entry_id, $values ) {
65 68
         global $wpdb;
66 69
 
@@ -286,6 +289,7 @@  discard block
 block discarded – undo
286 289
      * @param string|array $where
287 290
      * @param string $order_by
288 291
      * @param string $limit
292
+     * @param boolean $unique
289 293
      */
290 294
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
291 295
         global $wpdb;
Please login to merge, or discard this patch.
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -5,27 +5,27 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntryMeta {
7 7
 
8
-    /**
9
-     * @param string $meta_key
10
-     */
8
+	/**
9
+	 * @param string $meta_key
10
+	 */
11 11
 	public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
12
-        global $wpdb;
12
+		global $wpdb;
13 13
 
14
-        if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
-            // don't save blank fields
16
-            return;
17
-        }
14
+		if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
+			// don't save blank fields
16
+			return;
17
+		}
18 18
 
19
-        $new_values = array(
19
+		$new_values = array(
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21
-            'item_id'       => $entry_id,
22
-            'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
24
-        );
21
+			'item_id'       => $entry_id,
22
+			'field_id'      => $field_id,
23
+			'created_at'    => current_time('mysql', 1),
24
+		);
25 25
 
26
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
26
+		$new_values = apply_filters('frm_add_entry_meta', $new_values);
27 27
 
28
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
28
+		$query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
29 29
 
30 30
 		if ( $query_results ) {
31 31
 			self::clear_cache();
@@ -34,40 +34,40 @@  discard block
 block discarded – undo
34 34
 			$id = 0;
35 35
 		}
36 36
 
37
-        return $id;
38
-    }
37
+		return $id;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $meta_key
42
-     */
40
+	/**
41
+	 * @param string $meta_key
42
+	 */
43 43
 	public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
44
-        if ( ! $field_id ) {
45
-            return false;
46
-        }
44
+		if ( ! $field_id ) {
45
+			return false;
46
+		}
47 47
 
48
-        global $wpdb;
48
+		global $wpdb;
49 49
 
50
-        $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51
-        $values['meta_value'] = $meta_value;
52
-        $values = apply_filters('frm_update_entry_meta', $values);
50
+		$values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51
+		$values['meta_value'] = $meta_value;
52
+		$values = apply_filters('frm_update_entry_meta', $values);
53 53
 		if ( is_array($values['meta_value']) ) {
54 54
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
55 55
 		}
56
-        $meta_value = maybe_serialize($values['meta_value']);
56
+		$meta_value = maybe_serialize($values['meta_value']);
57 57
 
58
-        wp_cache_delete( $entry_id, 'frm_entry');
58
+		wp_cache_delete( $entry_id, 'frm_entry');
59 59
 		self::clear_cache();
60 60
 
61
-        return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62
-    }
61
+		return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62
+	}
63 63
 
64 64
 	public static function update_entry_metas( $entry_id, $values ) {
65
-        global $wpdb;
65
+		global $wpdb;
66 66
 
67 67
 		$prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
68 68
 
69
-        foreach ( $values as $field_id => $meta_value ) {
70
-            // set the value for the file upload field and add new tags (in Pro version)
69
+		foreach ( $values as $field_id => $meta_value ) {
70
+			// set the value for the file upload field and add new tags (in Pro version)
71 71
 			$meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id );
72 72
 
73 73
 			if ( $prev_values && in_array($field_id, $prev_values) ) {
@@ -85,39 +85,39 @@  discard block
 block discarded – undo
85 85
 			}
86 86
 		}
87 87
 
88
-        if ( empty($prev_values) ) {
89
-            return;
90
-        }
88
+		if ( empty($prev_values) ) {
89
+			return;
90
+		}
91 91
 
92
-        $prev_values = array_diff($prev_values, array_keys($values));
92
+		$prev_values = array_diff($prev_values, array_keys($values));
93 93
 
94
-        if ( empty($prev_values) ) {
95
-            return;
96
-        }
94
+		if ( empty($prev_values) ) {
95
+			return;
96
+		}
97 97
 
98 98
 		// prepare the query
99 99
 		$where = array( 'item_id' => $entry_id, 'field_id' => $prev_values );
100 100
 		FrmDb::get_where_clause_and_values( $where );
101 101
 
102
-        // Delete any leftovers
103
-        $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
102
+		// Delete any leftovers
103
+		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
104 104
 		self::clear_cache();
105
-    }
105
+	}
106 106
 
107 107
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
108
-        $metas = self::get_entry_meta_info($old_id);
109
-        foreach ( $metas as $meta ) {
110
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
111
-            unset($meta);
112
-        }
108
+		$metas = self::get_entry_meta_info($old_id);
109
+		foreach ( $metas as $meta ) {
110
+			self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
111
+			unset($meta);
112
+		}
113 113
 		self::clear_cache();
114
-    }
114
+	}
115 115
 
116 116
 	public static function delete_entry_meta( $entry_id, $field_id ) {
117
-        global $wpdb;
117
+		global $wpdb;
118 118
 		self::clear_cache();
119
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
120
-    }
119
+		return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
120
+	}
121 121
 
122 122
 	/**
123 123
 	 * Clear entry meta caching
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	}
143 143
 
144 144
 	public static function get_entry_meta_by_field( $entry_id, $field_id ) {
145
-        global $wpdb;
145
+		global $wpdb;
146 146
 
147 147
 		if ( is_object( $entry_id ) ) {
148 148
 			$entry = $entry_id;
@@ -155,24 +155,24 @@  discard block
 block discarded – undo
155 155
 
156 156
 		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
157 157
 			$result = $cached->metas[ $field_id ];
158
-            return stripslashes_deep($result);
159
-        }
158
+			return stripslashes_deep($result);
159
+		}
160 160
 
161 161
 		$get_table = $wpdb->prefix .'frm_item_metas';
162 162
 		$query = array( 'item_id' => $entry_id );
163
-        if ( is_numeric($field_id) ) {
163
+		if ( is_numeric($field_id) ) {
164 164
 			$query['field_id'] = $field_id;
165
-        } else {
165
+		} else {
166 166
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
167 167
 			$query['fi.field_key'] = $field_id;
168
-        }
168
+		}
169 169
 
170 170
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
171
-        $result = maybe_unserialize($result);
172
-        $result = stripslashes_deep($result);
171
+		$result = maybe_unserialize($result);
172
+		$result = stripslashes_deep($result);
173 173
 
174
-        return $result;
175
-    }
174
+		return $result;
175
+	}
176 176
 
177 177
 	public static function get_entry_meta( $entry_id, $field_id ) {
178 178
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmEntryMeta::get_entry_meta_by_field' );
@@ -180,117 +180,117 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	public static function get_entry_metas( $entry_id ) {
183
-        _deprecated_function( __FUNCTION__, '1.07.10');
183
+		_deprecated_function( __FUNCTION__, '1.07.10');
184 184
 
185
-        global $wpdb;
185
+		global $wpdb;
186 186
 		return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' );
187
-    }
187
+	}
188 188
 
189
-    public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
189
+	public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
190 190
 		$defaults = array( 'value' => false, 'unique' => false, 'stripslashes' => true, 'is_draft' => false );
191
-        $args = wp_parse_args( $args, $defaults );
191
+		$args = wp_parse_args( $args, $defaults );
192 192
 
193
-        $query = array();
194
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
195
-        $query = implode(' ', $query);
193
+		$query = array();
194
+		self::meta_field_query($field_id, $order, $limit, $args, $query);
195
+		$query = implode(' ', $query);
196 196
 
197
-        $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
198
-        $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
197
+		$cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
198
+		$values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
199 199
 
200
-        if ( ! $args['stripslashes'] ) {
201
-            return $values;
202
-        }
200
+		if ( ! $args['stripslashes'] ) {
201
+			return $values;
202
+		}
203 203
 
204 204
 		foreach ( $values as $k => $v ) {
205 205
 			$values[ $k ] = maybe_unserialize( $v );
206
-            unset($k, $v);
207
-        }
206
+			unset($k, $v);
207
+		}
208 208
 
209
-        return stripslashes_deep($values);
210
-    }
209
+		return stripslashes_deep($values);
210
+	}
211 211
 
212
-    /**
213
-     * @param string $order
214
-     * @param string $limit
215
-     */
212
+	/**
213
+	 * @param string $order
214
+	 * @param string $limit
215
+	 */
216 216
 	private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) {
217
-        global $wpdb;
218
-        $query[] = 'SELECT';
219
-        $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
220
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
221
-
222
-        if ( ! $args['is_draft'] ) {
223
-            $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
224
-        }
225
-
226
-        if ( is_numeric($field_id) ) {
227
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
228
-        } else {
229
-            $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
230
-        }
231
-
232
-        if ( ! $args['is_draft'] ) {
233
-            $query[] = 'AND e.is_draft=0';
234
-        }
235
-
236
-        if ( $args['value'] ) {
237
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
238
-        }
239
-        $query[] = $order . $limit;
240
-    }
217
+		global $wpdb;
218
+		$query[] = 'SELECT';
219
+		$query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
220
+		$query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
221
+
222
+		if ( ! $args['is_draft'] ) {
223
+			$query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
224
+		}
225
+
226
+		if ( is_numeric($field_id) ) {
227
+			$query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
228
+		} else {
229
+			$query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
230
+		}
231
+
232
+		if ( ! $args['is_draft'] ) {
233
+			$query[] = 'AND e.is_draft=0';
234
+		}
235
+
236
+		if ( $args['value'] ) {
237
+			$query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
238
+		}
239
+		$query[] = $order . $limit;
240
+	}
241 241
 
242 242
 	public static function get_entry_meta_info( $entry_id ) {
243 243
 		return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) );
244
-    }
244
+	}
245 245
 
246 246
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) {
247
-        global $wpdb;
248
-        $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
247
+		global $wpdb;
248
+		$query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
249 249
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
250 250
             FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id' .
251
-            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
251
+			FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
252 252
 
253
-        $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
254
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
253
+		$cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
254
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
255 255
 
256
-        if ( ! $results || ! $stripslashes ) {
257
-            return $results;
258
-        }
256
+		if ( ! $results || ! $stripslashes ) {
257
+			return $results;
258
+		}
259 259
 
260
-        foreach ( $results as $k => $result ) {
260
+		foreach ( $results as $k => $result ) {
261 261
 			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
262
-            unset($k, $result);
263
-        }
262
+			unset($k, $result);
263
+		}
264 264
 
265
-        return $results;
266
-    }
265
+		return $results;
266
+	}
267 267
 
268
-    public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
268
+	public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
269 269
 		$defaults = array(
270 270
 			'is_draft' => false,
271 271
 			'user_id'  => '',
272 272
 			'group_by' => '',
273 273
 		);
274
-        $args = wp_parse_args($args, $defaults);
274
+		$args = wp_parse_args($args, $defaults);
275 275
 
276
-        $query = array();
277
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
278
-        $query = implode(' ', $query);
276
+		$query = array();
277
+		self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
278
+		$query = implode(' ', $query);
279 279
 
280
-        $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
281
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
280
+		$cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
281
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
282 282
 
283
-        return $results;
284
-    }
283
+		return $results;
284
+	}
285 285
 
286
-    /**
287
-     * @param string|array $where
288
-     * @param string $order_by
289
-     * @param string $limit
290
-     */
286
+	/**
287
+	 * @param string|array $where
288
+	 * @param string $order_by
289
+	 * @param string $limit
290
+	 */
291 291
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
292
-        global $wpdb;
293
-        $query[] = 'SELECT';
292
+		global $wpdb;
293
+		$query[] = 'SELECT';
294 294
 
295 295
 		$defaults = array( 'return_parent_id' => false );
296 296
 		$args = array_merge( $defaults, $args );
@@ -301,91 +301,91 @@  discard block
 block discarded – undo
301 301
 			$query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id';
302 302
 		}
303 303
 
304
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
304
+		$query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
305 305
 
306
-        $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
307
-        if ( is_array($where) ) {
308
-            if ( ! $args['is_draft'] ) {
309
-                $where['e.is_draft'] = 0;
310
-            } else if ( $args['is_draft'] == 1 ) {
311
-                $where['e.is_draft'] = 1;
312
-            }
306
+		$query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
307
+		if ( is_array($where) ) {
308
+			if ( ! $args['is_draft'] ) {
309
+				$where['e.is_draft'] = 0;
310
+			} else if ( $args['is_draft'] == 1 ) {
311
+				$where['e.is_draft'] = 1;
312
+			}
313 313
 
314
-            if ( ! empty($args['user_id']) ) {
315
-                $where['e.user_id'] = $args['user_id'];
316
-            }
317
-            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
314
+			if ( ! empty($args['user_id']) ) {
315
+				$where['e.user_id'] = $args['user_id'];
316
+			}
317
+			$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
318 318
 
319 319
 			if ( $args['group_by'] ) {
320 320
 				$query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] );
321 321
 			}
322
-            return;
323
-        }
322
+			return;
323
+		}
324 324
 
325 325
 		$draft_where = $user_where = '';
326
-        if ( ! $args['is_draft'] ) {
326
+		if ( ! $args['is_draft'] ) {
327 327
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 );
328
-        } else if ( $args['is_draft'] == 1 ) {
328
+		} else if ( $args['is_draft'] == 1 ) {
329 329
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
330
-        }
331
-
332
-        if ( ! empty($args['user_id']) ) {
333
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
334
-        }
335
-
336
-        if ( strpos($where, ' GROUP BY ') ) {
337
-            // don't inject WHERE filtering after GROUP BY
338
-            $parts = explode(' GROUP BY ', $where);
339
-            $where = $parts[0];
340
-            $where .= $draft_where . $user_where;
341
-            $where .= ' GROUP BY '. $parts[1];
342
-        } else {
343
-            $where .= $draft_where . $user_where;
344
-        }
330
+		}
331
+
332
+		if ( ! empty($args['user_id']) ) {
333
+			$user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
334
+		}
335
+
336
+		if ( strpos($where, ' GROUP BY ') ) {
337
+			// don't inject WHERE filtering after GROUP BY
338
+			$parts = explode(' GROUP BY ', $where);
339
+			$where = $parts[0];
340
+			$where .= $draft_where . $user_where;
341
+			$where .= ' GROUP BY '. $parts[1];
342
+		} else {
343
+			$where .= $draft_where . $user_where;
344
+		}
345 345
 
346 346
 		// The query has already been prepared
347 347
 		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
348
-    }
348
+	}
349 349
 
350
-    public static function search_entry_metas( $search, $field_id = '', $operator ) {
351
-        $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
352
-        $results = wp_cache_get($cache_key, 'frm_entry');
353
-        if ( false !== $results ) {
354
-            return $results;
355
-        }
350
+	public static function search_entry_metas( $search, $field_id = '', $operator ) {
351
+		$cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
352
+		$results = wp_cache_get($cache_key, 'frm_entry');
353
+		if ( false !== $results ) {
354
+			return $results;
355
+		}
356 356
 
357
-        global $wpdb;
357
+		global $wpdb;
358 358
 		if ( is_array( $search ) ) {
359
-            $where = '';
359
+			$where = '';
360 360
 			foreach ( $search as $field => $value ) {
361 361
 				if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) {
362
-                    continue;
363
-                }
364
-
365
-                switch ( $field ) {
366
-                    case 'year':
367
-                        $value = '%'. $value;
368
-                    break;
369
-                    case 'month':
370
-                        $value .= '%';
371
-                    break;
372
-                    case 'day':
373
-                        $value = '%'. $value .'%';
374
-                }
375
-                $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
376
-            }
377
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
378
-            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
379
-        } else {
362
+					continue;
363
+				}
364
+
365
+				switch ( $field ) {
366
+					case 'year':
367
+						$value = '%'. $value;
368
+					break;
369
+					case 'month':
370
+						$value .= '%';
371
+					break;
372
+					case 'day':
373
+						$value = '%'. $value .'%';
374
+				}
375
+				$where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
376
+			}
377
+			$where .= $wpdb->prepare(' field_id=%d', $field_id);
378
+			$query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
379
+		} else {
380 380
 			if ( $operator == 'LIKE' ) {
381
-                $search = '%' . $search . '%';
381
+				$search = '%' . $search . '%';
382 382
 			}
383
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
384
-        }
383
+			$query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
384
+		}
385 385
 
386
-        $results = $wpdb->get_col($query, 0);
387
-        wp_cache_set($cache_key, $results, 'frm_entry', 300);
386
+		$results = $wpdb->get_col($query, 0);
387
+		wp_cache_set($cache_key, $results, 'frm_entry', 300);
388 388
 
389
-        return $results;
390
-    }
389
+		return $results;
390
+	}
391 391
 }
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 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
 
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21 21
             'item_id'       => $entry_id,
22 22
             'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
23
+            'created_at'    => current_time( 'mysql', 1 ),
24 24
         );
25 25
 
26
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
26
+        $new_values = apply_filters( 'frm_add_entry_meta', $new_values );
27 27
 
28
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
28
+        $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
29 29
 
30 30
 		if ( $query_results ) {
31 31
 			self::clear_cache();
@@ -49,32 +49,32 @@  discard block
 block discarded – undo
49 49
 
50 50
         $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51 51
         $values['meta_value'] = $meta_value;
52
-        $values = apply_filters('frm_update_entry_meta', $values);
53
-		if ( is_array($values['meta_value']) ) {
52
+        $values = apply_filters( 'frm_update_entry_meta', $values );
53
+		if ( is_array( $values['meta_value'] ) ) {
54 54
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
55 55
 		}
56
-        $meta_value = maybe_serialize($values['meta_value']);
56
+        $meta_value = maybe_serialize( $values['meta_value'] );
57 57
 
58
-        wp_cache_delete( $entry_id, 'frm_entry');
58
+        wp_cache_delete( $entry_id, 'frm_entry' );
59 59
 		self::clear_cache();
60 60
 
61
-        return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
61
+        return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62 62
     }
63 63
 
64 64
 	public static function update_entry_metas( $entry_id, $values ) {
65 65
         global $wpdb;
66 66
 
67
-		$prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
67
+		$prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
68 68
 
69 69
         foreach ( $values as $field_id => $meta_value ) {
70 70
             // set the value for the file upload field and add new tags (in Pro version)
71 71
 			$meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id );
72 72
 
73
-			if ( $prev_values && in_array($field_id, $prev_values) ) {
73
+			if ( $prev_values && in_array( $field_id, $prev_values ) ) {
74 74
 
75 75
 				if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
76 76
 					// remove blank fields
77
-					unset( $values[ $field_id ] );
77
+					unset( $values[$field_id] );
78 78
 				} else {
79 79
 					// if value exists, then update it
80 80
 					self::update_entry_meta( $entry_id, $field_id, '', $meta_value );
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 			}
86 86
 		}
87 87
 
88
-        if ( empty($prev_values) ) {
88
+        if ( empty( $prev_values ) ) {
89 89
             return;
90 90
         }
91 91
 
92
-        $prev_values = array_diff($prev_values, array_keys($values));
92
+        $prev_values = array_diff( $prev_values, array_keys( $values ) );
93 93
 
94
-        if ( empty($prev_values) ) {
94
+        if ( empty( $prev_values ) ) {
95 95
             return;
96 96
         }
97 97
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
     }
106 106
 
107 107
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
108
-        $metas = self::get_entry_meta_info($old_id);
108
+        $metas = self::get_entry_meta_info( $old_id );
109 109
         foreach ( $metas as $meta ) {
110
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
111
-            unset($meta);
110
+            self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value );
111
+            unset( $meta );
112 112
         }
113 113
 		self::clear_cache();
114 114
     }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	public static function delete_entry_meta( $entry_id, $field_id ) {
117 117
         global $wpdb;
118 118
 		self::clear_cache();
119
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
119
+        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) );
120 120
     }
121 121
 
122 122
 	/**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public static function get_meta_value( $entry, $field_id ) {
137 137
 		if ( isset( $entry->metas ) ) {
138
-			return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false;
138
+			return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false;
139 139
 		} else {
140 140
 			return self::get_entry_meta_by_field( $entry->id, $field_id );
141 141
 		}
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 			$cached = FrmAppHelper::check_cache( $entry_id, 'frm_entry' );
154 154
 		}
155 155
 
156
-		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
157
-			$result = $cached->metas[ $field_id ];
158
-            return stripslashes_deep($result);
156
+		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) {
157
+			$result = $cached->metas[$field_id];
158
+            return stripslashes_deep( $result );
159 159
         }
160 160
 
161
-		$get_table = $wpdb->prefix .'frm_item_metas';
161
+		$get_table = $wpdb->prefix . 'frm_item_metas';
162 162
 		$query = array( 'item_id' => $entry_id );
163
-        if ( is_numeric($field_id) ) {
163
+        if ( is_numeric( $field_id ) ) {
164 164
 			$query['field_id'] = $field_id;
165 165
         } else {
166 166
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
         }
169 169
 
170 170
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
171
-        $result = maybe_unserialize($result);
172
-        $result = stripslashes_deep($result);
171
+        $result = maybe_unserialize( $result );
172
+        $result = stripslashes_deep( $result );
173 173
 
174 174
         return $result;
175 175
     }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	public static function get_entry_metas( $entry_id ) {
183
-        _deprecated_function( __FUNCTION__, '1.07.10');
183
+        _deprecated_function( __FUNCTION__, '1.07.10' );
184 184
 
185 185
         global $wpdb;
186 186
 		return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' );
@@ -191,22 +191,22 @@  discard block
 block discarded – undo
191 191
         $args = wp_parse_args( $args, $defaults );
192 192
 
193 193
         $query = array();
194
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
195
-        $query = implode(' ', $query);
194
+        self::meta_field_query( $field_id, $order, $limit, $args, $query );
195
+        $query = implode( ' ', $query );
196 196
 
197
-        $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
198
-        $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
197
+        $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
198
+        $values = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_col' );
199 199
 
200 200
         if ( ! $args['stripslashes'] ) {
201 201
             return $values;
202 202
         }
203 203
 
204 204
 		foreach ( $values as $k => $v ) {
205
-			$values[ $k ] = maybe_unserialize( $v );
206
-            unset($k, $v);
205
+			$values[$k] = maybe_unserialize( $v );
206
+            unset( $k, $v );
207 207
         }
208 208
 
209
-        return stripslashes_deep($values);
209
+        return stripslashes_deep( $values );
210 210
     }
211 211
 
212 212
     /**
@@ -217,16 +217,16 @@  discard block
 block discarded – undo
217 217
         global $wpdb;
218 218
         $query[] = 'SELECT';
219 219
         $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
220
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
220
+        $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em ';
221 221
 
222 222
         if ( ! $args['is_draft'] ) {
223
-            $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
223
+            $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
224 224
         }
225 225
 
226
-        if ( is_numeric($field_id) ) {
227
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
226
+        if ( is_numeric( $field_id ) ) {
227
+            $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id );
228 228
         } else {
229
-            $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
229
+            $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
230 230
         }
231 231
 
232 232
         if ( ! $args['is_draft'] ) {
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         }
235 235
 
236 236
         if ( $args['value'] ) {
237
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
237
+            $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] );
238 238
         }
239 239
         $query[] = $order . $limit;
240 240
     }
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
         global $wpdb;
248 248
         $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
249 249
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
250
-            FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id' .
251
-            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
250
+            FROM '. $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
251
+            FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
252 252
 
253
-        $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
254
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
253
+        $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
254
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) );
255 255
 
256 256
         if ( ! $results || ! $stripslashes ) {
257 257
             return $results;
258 258
         }
259 259
 
260 260
         foreach ( $results as $k => $result ) {
261
-			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
262
-            unset($k, $result);
261
+			$results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
262
+            unset( $k, $result );
263 263
         }
264 264
 
265 265
         return $results;
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
 			'user_id'  => '',
272 272
 			'group_by' => '',
273 273
 		);
274
-        $args = wp_parse_args($args, $defaults);
274
+        $args = wp_parse_args( $args, $defaults );
275 275
 
276 276
         $query = array();
277
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
278
-        $query = implode(' ', $query);
277
+        self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query );
278
+        $query = implode( ' ', $query );
279 279
 
280
-        $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
281
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
280
+        $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
281
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
282 282
 
283 283
         return $results;
284 284
     }
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 			$query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id';
302 302
 		}
303 303
 
304
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
304
+        $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
305 305
 
306
-        $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
307
-        if ( is_array($where) ) {
306
+        $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
307
+        if ( is_array( $where ) ) {
308 308
             if ( ! $args['is_draft'] ) {
309 309
                 $where['e.is_draft'] = 0;
310 310
             } else if ( $args['is_draft'] == 1 ) {
311 311
                 $where['e.is_draft'] = 1;
312 312
             }
313 313
 
314
-            if ( ! empty($args['user_id']) ) {
314
+            if ( ! empty( $args['user_id'] ) ) {
315 315
                 $where['e.user_id'] = $args['user_id'];
316 316
             }
317
-            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
317
+            $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
318 318
 
319 319
 			if ( $args['group_by'] ) {
320
-				$query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] );
320
+				$query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
321 321
 			}
322 322
             return;
323 323
         }
@@ -329,27 +329,27 @@  discard block
 block discarded – undo
329 329
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
330 330
         }
331 331
 
332
-        if ( ! empty($args['user_id']) ) {
333
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
332
+        if ( ! empty( $args['user_id'] ) ) {
333
+            $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] );
334 334
         }
335 335
 
336
-        if ( strpos($where, ' GROUP BY ') ) {
336
+        if ( strpos( $where, ' GROUP BY ' ) ) {
337 337
             // don't inject WHERE filtering after GROUP BY
338
-            $parts = explode(' GROUP BY ', $where);
338
+            $parts = explode( ' GROUP BY ', $where );
339 339
             $where = $parts[0];
340 340
             $where .= $draft_where . $user_where;
341
-            $where .= ' GROUP BY '. $parts[1];
341
+            $where .= ' GROUP BY ' . $parts[1];
342 342
         } else {
343 343
             $where .= $draft_where . $user_where;
344 344
         }
345 345
 
346 346
 		// The query has already been prepared
347
-		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
347
+		$query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
348 348
     }
349 349
 
350 350
     public static function search_entry_metas( $search, $field_id = '', $operator ) {
351
-        $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
352
-        $results = wp_cache_get($cache_key, 'frm_entry');
351
+        $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
352
+        $results = wp_cache_get( $cache_key, 'frm_entry' );
353 353
         if ( false !== $results ) {
354 354
             return $results;
355 355
         }
@@ -364,27 +364,27 @@  discard block
 block discarded – undo
364 364
 
365 365
                 switch ( $field ) {
366 366
                     case 'year':
367
-                        $value = '%'. $value;
367
+                        $value = '%' . $value;
368 368
                     break;
369 369
                     case 'month':
370 370
                         $value .= '%';
371 371
                     break;
372 372
                     case 'day':
373
-                        $value = '%'. $value .'%';
373
+                        $value = '%' . $value . '%';
374 374
                 }
375
-                $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
375
+                $where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value );
376 376
             }
377
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
378
-            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
377
+            $where .= $wpdb->prepare( ' field_id=%d', $field_id );
378
+            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas" . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
379 379
         } else {
380 380
 			if ( $operator == 'LIKE' ) {
381 381
                 $search = '%' . $search . '%';
382 382
 			}
383
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
383
+            $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id );
384 384
         }
385 385
 
386
-        $results = $wpdb->get_col($query, 0);
387
-        wp_cache_set($cache_key, $results, 'frm_entry', 300);
386
+        $results = $wpdb->get_col( $query, 0 );
387
+        wp_cache_set( $cache_key, $results, 'frm_entry', 300 );
388 388
 
389 389
         return $results;
390 390
     }
Please login to merge, or discard this patch.
classes/models/FrmStyle.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7
-	 * @param int|string $id The id of the stylsheet or 'default'
7
+	 * @param integer $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10 10
         $this->id = $id;
Please login to merge, or discard this patch.
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -1,52 +1,52 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStyle {
3
-    public $number = false;	// Unique ID number of the current instance.
3
+	public $number = false;	// Unique ID number of the current instance.
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7 7
 	 * @param int|string $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10
-        $this->id = $id;
11
-    }
10
+		$this->id = $id;
11
+	}
12 12
 
13
-    public function get_new() {
13
+	public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = pow(36, 6);
17
-        $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
-
20
-        $style = array(
21
-            'post_type'     => FrmStylesController::$post_type,
22
-            'ID'            => '',
23
-            'post_title'    => __( 'New Style', 'formidable' ),
24
-            'post_name'     => $key,
25
-            'post_content'  => $this->get_defaults(),
26
-            'menu_order'    => '',
27
-            'post_status'   => 'publish',
28
-        );
16
+		$max_slug_value = pow(36, 6);
17
+		$min_slug_value = 37; // we want to have at least 2 characters in the slug
18
+		$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
+
20
+		$style = array(
21
+			'post_type'     => FrmStylesController::$post_type,
22
+			'ID'            => '',
23
+			'post_title'    => __( 'New Style', 'formidable' ),
24
+			'post_name'     => $key,
25
+			'post_content'  => $this->get_defaults(),
26
+			'menu_order'    => '',
27
+			'post_status'   => 'publish',
28
+		);
29 29
 
30
-        return (object) $style;
31
-    }
30
+		return (object) $style;
31
+	}
32 32
 
33 33
 	public function save( $settings ) {
34 34
 		return FrmAppHelper::save_settings( $settings, 'frm_styles' );
35
-    }
35
+	}
36 36
 
37 37
 	public function duplicate( $id ) {
38
-        // duplicating is a pro feature
39
-    }
38
+		// duplicating is a pro feature
39
+	}
40 40
 
41
-    public function update( $id = 'default' ) {
41
+	public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44 44
  		if ( empty($id) ) {
45
- 		     $new_style = (array) $this->get_new();
46
- 		     $all_instances[] = $new_style;
45
+ 			 $new_style = (array) $this->get_new();
46
+ 			 $all_instances[] = $new_style;
47 47
  		}
48 48
 
49
-        $action_ids = array();
49
+		$action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52 52
  			$new_instance = stripslashes_deep( (array) $new_instance);
@@ -54,40 +54,40 @@  discard block
 block discarded – undo
54 54
  			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55 55
 				$all_instances[ $number ] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
- 			        // this style was set to default, so remove default setting on previous default style
59
- 			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
61
- 			    }
57
+ 				if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
+ 					// this style was set to default, so remove default setting on previous default style
59
+ 					$new_instance['menu_order'] = 0;
60
+ 					$action_ids[] = $this->save($new_instance);
61
+ 				}
62 62
 
63
- 			    // don't continue if not saving this style
64
- 			    continue;
63
+ 				// don't continue if not saving this style
64
+ 				continue;
65 65
  			}
66 66
 
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+			$new_instance['post_status']  = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
74
-                $new_instance['post_name'] = $new_instance['post_title'];
75
-            }
73
+			if ( empty($id) ) {
74
+				$new_instance['post_name'] = $new_instance['post_title'];
75
+			}
76 76
 
77
-            $default_settings = $this->get_defaults();
77
+			$default_settings = $this->get_defaults();
78 78
 
79
-            foreach ( $default_settings as $setting => $default ) {
79
+			foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
81
-                    //if is a color
81
+					//if is a color
82 82
 					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
83 83
 				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
84 84
 					$new_instance['post_content'][ $setting ] = 0;
85
-                }
86
-            }
85
+				}
86
+			}
87 87
 
88 88
 			$all_instances[ $number ] = $new_instance;
89 89
 
90
-            $action_ids[] = $this->save($new_instance);
90
+			$action_ids[] = $this->save($new_instance);
91 91
 
92 92
  		}
93 93
 
@@ -96,74 +96,74 @@  discard block
 block discarded – undo
96 96
  		return $action_ids;
97 97
  	}
98 98
 
99
-    /**
100
-     * Create static css file
101
-     */
99
+	/**
100
+	 * Create static css file
101
+	 */
102 102
 	public function save_settings( $styles ) {
103
-        $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
103
+		$filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
104 104
 
105
-        if ( ! is_file($filename) ) {
106
-            return;
107
-        }
105
+		if ( ! is_file($filename) ) {
106
+			return;
107
+		}
108 108
 
109
-        $defaults = $this->get_defaults();
110
-        $uploads = wp_upload_dir();
111
-        $target_path = $uploads['basedir'] .'/formidable';
112
-        $needed_dirs = array( $target_path, $target_path .'/css' );
113
-        $dirs_exist = true;
109
+		$defaults = $this->get_defaults();
110
+		$uploads = wp_upload_dir();
111
+		$target_path = $uploads['basedir'] .'/formidable';
112
+		$needed_dirs = array( $target_path, $target_path .'/css' );
113
+		$dirs_exist = true;
114 114
 
115
-        $saving = true;
116
-        $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
115
+		$saving = true;
116
+		$css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
117 117
 
118
-        ob_start();
119
-        $frm_style = $this;
120
-        include($filename);
118
+		ob_start();
119
+		$frm_style = $this;
120
+		include($filename);
121 121
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
122
-        ob_end_clean();
122
+		ob_end_clean();
123 123
 
124
-        $access_type = get_filesystem_method();
125
-        if ( $access_type === 'direct' ) {
126
-        	$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
124
+		$access_type = get_filesystem_method();
125
+		if ( $access_type === 'direct' ) {
126
+			$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
127 127
 		} else {
128 128
 			$creds = $this->get_ftp_creds( $access_type );
129 129
 		}
130 130
 
131 131
 		if ( ! empty( $creds ) ) {
132
-        	// initialize the API
133
-        	if ( ! WP_Filesystem( $creds ) ) {
134
-        		// any problems and we exit
135
-        		$dirs_exist = false;
132
+			// initialize the API
133
+			if ( ! WP_Filesystem( $creds ) ) {
134
+				// any problems and we exit
135
+				$dirs_exist = false;
136 136
 			}
137 137
 
138
-            if ( $dirs_exist ) {
139
-	        	global $wp_filesystem;
138
+			if ( $dirs_exist ) {
139
+				global $wp_filesystem;
140 140
 
141
-            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
-            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
141
+				$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
+				$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
143 143
 
144
-                // Create the directories if need be:
145
-            	foreach ( $needed_dirs as $_dir ) {
146
-                    // Only check to see if the Dir exists upon creation failure. Less I/O this way.
147
-            		if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) {
148
-            			$dirs_exist = false;
149
-                    }
150
-            	}
144
+				// Create the directories if need be:
145
+				foreach ( $needed_dirs as $_dir ) {
146
+					// Only check to see if the Dir exists upon creation failure. Less I/O this way.
147
+					if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) {
148
+						$dirs_exist = false;
149
+					}
150
+				}
151 151
 
152
-                $index_path = $target_path .'/index.php';
153
-                $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
152
+				$index_path = $target_path .'/index.php';
153
+				$wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
154 154
 
155
-                // only write the file if the folders exist
156
-                if ( $dirs_exist ) {
157
-                    $css_file = $target_path .'/css/formidablepro.css';
158
-                    $wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159
-                }
160
-            }
161
-        }
155
+				// only write the file if the folders exist
156
+				if ( $dirs_exist ) {
157
+					$css_file = $target_path .'/css/formidablepro.css';
158
+					$wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159
+				}
160
+			}
161
+		}
162 162
 
163
-        update_option('frmpro_css', $css);
163
+		update_option('frmpro_css', $css);
164 164
 
165
-        delete_transient('frmpro_css');
166
-        set_transient('frmpro_css', $css);
165
+		delete_transient('frmpro_css');
166
+		set_transient('frmpro_css', $css);
167 167
 	}
168 168
 
169 169
 	private function get_ftp_creds( $type ) {
@@ -217,264 +217,264 @@  discard block
 block discarded – undo
217 217
 	}
218 218
 
219 219
 	public function destroy( $id ) {
220
-        return wp_delete_post($id);
221
-    }
220
+		return wp_delete_post($id);
221
+	}
222 222
 
223
-    public function get_one() {
224
-        if ( 'default' == $this->id ) {
225
-            $style = $this->get_default_style();
226
-            if ( $style ) {
227
-                $this->id = $style->ID;
228
-            } else {
229
-                $this->id = 0;
230
-            }
231
-            return $style;
232
-        }
223
+	public function get_one() {
224
+		if ( 'default' == $this->id ) {
225
+			$style = $this->get_default_style();
226
+			if ( $style ) {
227
+				$this->id = $style->ID;
228
+			} else {
229
+				$this->id = 0;
230
+			}
231
+			return $style;
232
+		}
233 233
 
234
-        $style = get_post($this->id);
234
+		$style = get_post($this->id);
235 235
 
236
-        if ( ! $style ) {
237
-            return $style;
238
-        }
236
+		if ( ! $style ) {
237
+			return $style;
238
+		}
239 239
 
240
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
240
+		$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
241 241
 
242
-        $default_values = $this->get_defaults();
242
+		$default_values = $this->get_defaults();
243 243
 
244
-        // fill default values
245
-        $style->post_content = $this->override_defaults($style->post_content);
246
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
244
+		// fill default values
245
+		$style->post_content = $this->override_defaults($style->post_content);
246
+		$style->post_content = wp_parse_args( $style->post_content, $default_values);
247 247
 
248
-        return $style;
249
-    }
248
+		return $style;
249
+	}
250 250
 
251
-    public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
252
-        $post_atts = array(
251
+	public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
252
+		$post_atts = array(
253 253
 			'post_type'   => FrmStylesController::$post_type,
254 254
 			'post_status' => 'publish',
255 255
 			'numberposts' => $limit,
256 256
 			'orderby'     => $orderby,
257 257
 			'order'       => $order,
258
-        );
259
-
260
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
261
-
262
-        if ( empty($temp_styles) ) {
263
-            global $wpdb;
264
-            // make sure there wasn't a conflict with the query
265
-            $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
267
-
268
-            if ( empty($temp_styles) ) {
269
-                // create a new style if there are none
270
-         		$new = $this->get_new();
271
-         		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272
-         		$new->menu_order = 1;
273
-         		$new = $this->save( (array) $new);
274
-         		$this->update('default');
275
-
276
-                $post_atts['include'] = $new;
277
-
278
-                $temp_styles = get_posts( $post_atts );
279
-            }
280
-        }
281
-
282
-        $default_values = $this->get_defaults();
283
-        $default_style = false;
284
-
285
-        $styles = array();
286
-        foreach ( $temp_styles as $style ) {
287
-            $this->id = $style->ID;
288
-            if ( $style->menu_order ) {
289
-                if ( $default_style ) {
290
-                    // only return one default
291
-                    $style->menu_order = 0;
292
-                } else {
293
-                    // check for a default style
294
-                    $default_style = $style->ID;
295
-                }
296
-            }
297
-
298
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
299
-
300
-            // fill default values
301
-            $style->post_content = $this->override_defaults($style->post_content);
302
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
258
+		);
259
+
260
+		$temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
261
+
262
+		if ( empty($temp_styles) ) {
263
+			global $wpdb;
264
+			// make sure there wasn't a conflict with the query
265
+			$query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
+			$temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
267
+
268
+			if ( empty($temp_styles) ) {
269
+				// create a new style if there are none
270
+		 		$new = $this->get_new();
271
+		 		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272
+		 		$new->menu_order = 1;
273
+		 		$new = $this->save( (array) $new);
274
+		 		$this->update('default');
275
+
276
+				$post_atts['include'] = $new;
277
+
278
+				$temp_styles = get_posts( $post_atts );
279
+			}
280
+		}
281
+
282
+		$default_values = $this->get_defaults();
283
+		$default_style = false;
284
+
285
+		$styles = array();
286
+		foreach ( $temp_styles as $style ) {
287
+			$this->id = $style->ID;
288
+			if ( $style->menu_order ) {
289
+				if ( $default_style ) {
290
+					// only return one default
291
+					$style->menu_order = 0;
292
+				} else {
293
+					// check for a default style
294
+					$default_style = $style->ID;
295
+				}
296
+			}
297
+
298
+			$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
299
+
300
+			// fill default values
301
+			$style->post_content = $this->override_defaults($style->post_content);
302
+			$style->post_content = wp_parse_args( $style->post_content, $default_values);
303 303
 
304 304
 			$styles[ $style->ID ] = $style;
305
-        }
305
+		}
306 306
 
307
-        if ( ! $default_style ) {
308
-            $default_style = reset($styles);
307
+		if ( ! $default_style ) {
308
+			$default_style = reset($styles);
309 309
 			$styles[ $default_style->ID ]->menu_order = 1;
310
-        }
310
+		}
311 311
 
312
-        return $styles;
313
-    }
312
+		return $styles;
313
+	}
314 314
 
315 315
 	public function get_default_style( $styles = null ) {
316
-        if ( ! isset($styles) ) {
316
+		if ( ! isset($styles) ) {
317 317
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
318
-        }
318
+		}
319 319
 
320
-        foreach ( $styles as $style ) {
321
-            if ( $style->menu_order ) {
322
-                return $style;
323
-            }
324
-        }
325
-    }
320
+		foreach ( $styles as $style ) {
321
+			if ( $style->menu_order ) {
322
+				return $style;
323
+			}
324
+		}
325
+	}
326 326
 
327 327
 	public function override_defaults( $settings ) {
328
-	    if ( ! is_array($settings) ) {
329
-	        return $settings;
330
-	    }
331
-
332
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
333
-
334
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
335
-	        $settings['form_desc_size'] = $settings['description_font_size'];
336
-	        $settings['form_desc_color'] = $settings['description_color'];
337
-	        $settings['title_color'] = $settings['label_color'];
338
-	    }
339
-
340
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
341
-	        $settings['section_color'] = $settings['label_color'];
342
-	        $settings['section_border_color'] = $settings['border_color'];
343
-	    }
344
-
345
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
346
-	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347
-	        $settings['submit_hover_color'] = $settings['submit_text_color'];
348
-	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
349
-
350
-	        $settings['submit_active_bg_color'] = $settings['submit_bg_color'];
351
-	        $settings['submit_active_color'] = $settings['submit_text_color'];
352
-            $settings['submit_active_border_color'] = $settings['submit_border_color'];
353
-	    }
354
-
355
-	    return $settings;
328
+		if ( ! is_array($settings) ) {
329
+			return $settings;
330
+		}
331
+
332
+		$settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
333
+
334
+		if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
335
+			$settings['form_desc_size'] = $settings['description_font_size'];
336
+			$settings['form_desc_color'] = $settings['description_color'];
337
+			$settings['title_color'] = $settings['label_color'];
338
+		}
339
+
340
+		if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
341
+			$settings['section_color'] = $settings['label_color'];
342
+			$settings['section_border_color'] = $settings['border_color'];
343
+		}
344
+
345
+		if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
346
+			$settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347
+			$settings['submit_hover_color'] = $settings['submit_text_color'];
348
+			$settings['submit_hover_border_color'] = $settings['submit_border_color'];
349
+
350
+			$settings['submit_active_bg_color'] = $settings['submit_bg_color'];
351
+			$settings['submit_active_color'] = $settings['submit_text_color'];
352
+			$settings['submit_active_border_color'] = $settings['submit_border_color'];
353
+		}
354
+
355
+		return $settings;
356 356
 	}
357 357
 
358 358
 	public function get_defaults() {
359
-        return array(
360
-            'theme_css'         => 'ui-lightness',
361
-            'theme_name'        => 'UI Lightness',
359
+		return array(
360
+			'theme_css'         => 'ui-lightness',
361
+			'theme_name'        => 'UI Lightness',
362 362
 
363 363
 			'center_form'		=> '',
364
-            'form_width'        => '100%',
365
-            'form_align'        => 'left',
366
-            'direction'         => is_rtl() ? 'rtl' : 'ltr',
367
-            'fieldset'          => '0px',
368
-            'fieldset_color'    => '000000',
369
-            'fieldset_padding'  => '0 0 15px 0',
370
-            'fieldset_bg_color' => '',
371
-
372
-            'title_size'        => '20px',
373
-            'title_color'       => '444444',
374
-            'form_desc_size'    => '14px',
375
-            'form_desc_color'   => '666666',
376
-
377
-            'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
378
-            'font_size'         => '14px',
379
-            'label_color'       => '444444',
380
-            'weight'            => 'bold',
381
-            'position'          => 'none',
382
-            'align'             => 'left',
383
-            'width'             => '150px',
384
-            'required_color'    => 'B94A48',
385
-            'required_weight'   => 'bold',
386
-            'label_padding'     => '0 0 3px 0',
387
-
388
-            'description_font_size' => '12px',
389
-            'description_color' => '666666',
390
-            'description_weight' => 'normal',
391
-            'description_style' => 'normal',
392
-            'description_align' => 'left',
393
-
394
-            'field_font_size'   => '14px',
395
-            'field_height' 		=> '32px',
396
-            'line_height'		=> 'normal',
397
-            'field_width'       => '100%',
398
-            'auto_width'        => false,
399
-            'field_pad'         => '6px 10px',
400
-            'field_margin'      => '20px',
401
-            'text_color'        => '555555',
402
-            //'border_color_hv'   => 'cccccc',
403
-            'border_color'      => 'cccccc',
404
-            'field_border_width' => '1px',
405
-            'field_border_style' => 'solid',
406
-
407
-            'bg_color'          => 'ffffff',
408
-            //'bg_color_hv'       => 'ffffff',
409
-            'bg_color_active'   => 'ffffff',
364
+			'form_width'        => '100%',
365
+			'form_align'        => 'left',
366
+			'direction'         => is_rtl() ? 'rtl' : 'ltr',
367
+			'fieldset'          => '0px',
368
+			'fieldset_color'    => '000000',
369
+			'fieldset_padding'  => '0 0 15px 0',
370
+			'fieldset_bg_color' => '',
371
+
372
+			'title_size'        => '20px',
373
+			'title_color'       => '444444',
374
+			'form_desc_size'    => '14px',
375
+			'form_desc_color'   => '666666',
376
+
377
+			'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
378
+			'font_size'         => '14px',
379
+			'label_color'       => '444444',
380
+			'weight'            => 'bold',
381
+			'position'          => 'none',
382
+			'align'             => 'left',
383
+			'width'             => '150px',
384
+			'required_color'    => 'B94A48',
385
+			'required_weight'   => 'bold',
386
+			'label_padding'     => '0 0 3px 0',
387
+
388
+			'description_font_size' => '12px',
389
+			'description_color' => '666666',
390
+			'description_weight' => 'normal',
391
+			'description_style' => 'normal',
392
+			'description_align' => 'left',
393
+
394
+			'field_font_size'   => '14px',
395
+			'field_height' 		=> '32px',
396
+			'line_height'		=> 'normal',
397
+			'field_width'       => '100%',
398
+			'auto_width'        => false,
399
+			'field_pad'         => '6px 10px',
400
+			'field_margin'      => '20px',
401
+			'text_color'        => '555555',
402
+			//'border_color_hv'   => 'cccccc',
403
+			'border_color'      => 'cccccc',
404
+			'field_border_width' => '1px',
405
+			'field_border_style' => 'solid',
406
+
407
+			'bg_color'          => 'ffffff',
408
+			//'bg_color_hv'       => 'ffffff',
409
+			'bg_color_active'   => 'ffffff',
410 410
 			'border_color_active' => '66afe9',
411
-            'text_color_error'  => '444444',
412
-            'bg_color_error'    => 'ffffff',
411
+			'text_color_error'  => '444444',
412
+			'bg_color_error'    => 'ffffff',
413 413
 			'border_color_error' => 'B94A48',
414 414
 			'border_width_error' => '1px',
415 415
 			'border_style_error' => 'solid',
416
-            'bg_color_disabled' => 'ffffff',
417
-            'border_color_disabled' => 'E5E5E5',
418
-            'text_color_disabled' => 'A1A1A1',
419
-
420
-            'radio_align'       => 'block',
421
-            'check_align'       => 'block',
422
-            'check_font_size'   => '13px',
423
-            'check_label_color' => '444444',
424
-            'check_weight'      => 'normal',
425
-
426
-            'section_font_size' => '18px',
427
-            'section_color'     => '444444',
428
-            'section_weight'    => 'bold',
429
-            'section_pad'       => '15px 0 3px 0',
430
-            'section_mar_top'   => '15px',
416
+			'bg_color_disabled' => 'ffffff',
417
+			'border_color_disabled' => 'E5E5E5',
418
+			'text_color_disabled' => 'A1A1A1',
419
+
420
+			'radio_align'       => 'block',
421
+			'check_align'       => 'block',
422
+			'check_font_size'   => '13px',
423
+			'check_label_color' => '444444',
424
+			'check_weight'      => 'normal',
425
+
426
+			'section_font_size' => '18px',
427
+			'section_color'     => '444444',
428
+			'section_weight'    => 'bold',
429
+			'section_pad'       => '15px 0 3px 0',
430
+			'section_mar_top'   => '15px',
431 431
 			'section_mar_bottom' => '12px',
432
-            'section_bg_color'  => '',
433
-            'section_border_color' => 'e8e8e8',
434
-            'section_border_width' => '2px',
435
-            'section_border_style' => 'solid',
436
-            'section_border_loc' => '-top',
437
-            'collapse_icon'     => '6',
438
-            'collapse_pos'      => 'after',
439
-            'repeat_icon'       => '1',
440
-
441
-            'submit_style'      => false,
442
-            'submit_font_size'  => '14px',
443
-            'submit_width'      => 'auto',
444
-            'submit_height'     => 'auto',
445
-            'submit_bg_color'   => 'ffffff',
446
-            'submit_border_color' => 'cccccc',
447
-            'submit_border_width' => '1px',
448
-            'submit_text_color' => '444444',
449
-            'submit_weight'     => 'normal',
450
-            'submit_border_radius' => '4px',
451
-            'submit_bg_img'     => '',
452
-            'submit_margin'     => '10px',
453
-            'submit_padding'    => '6px 11px',
454
-            'submit_shadow_color' => 'eeeeee',
455
-            'submit_hover_bg_color' => 'efefef',
456
-            'submit_hover_color' => '444444',
457
-            'submit_hover_border_color' => 'cccccc',
458
-            'submit_active_bg_color' => 'efefef',
459
-            'submit_active_color' => '444444',
460
-            'submit_active_border_color' => 'cccccc',
461
-
462
-            'border_radius'     => '4px',
463
-            'error_bg'          => 'F2DEDE',
464
-            'error_border'      => 'EBCCD1',
465
-            'error_text'        => 'B94A48',
466
-            'error_font_size'   => '14px',
467
-
468
-            'success_bg_color'  => 'DFF0D8',
469
-            'success_border_color' => 'D6E9C6',
470
-            'success_text_color' => '468847',
471
-            'success_font_size' => '14px',
472
-
473
-            'important_style'   => false,
474
-
475
-            'custom_css'        => '',
476
-        );
477
-    }
432
+			'section_bg_color'  => '',
433
+			'section_border_color' => 'e8e8e8',
434
+			'section_border_width' => '2px',
435
+			'section_border_style' => 'solid',
436
+			'section_border_loc' => '-top',
437
+			'collapse_icon'     => '6',
438
+			'collapse_pos'      => 'after',
439
+			'repeat_icon'       => '1',
440
+
441
+			'submit_style'      => false,
442
+			'submit_font_size'  => '14px',
443
+			'submit_width'      => 'auto',
444
+			'submit_height'     => 'auto',
445
+			'submit_bg_color'   => 'ffffff',
446
+			'submit_border_color' => 'cccccc',
447
+			'submit_border_width' => '1px',
448
+			'submit_text_color' => '444444',
449
+			'submit_weight'     => 'normal',
450
+			'submit_border_radius' => '4px',
451
+			'submit_bg_img'     => '',
452
+			'submit_margin'     => '10px',
453
+			'submit_padding'    => '6px 11px',
454
+			'submit_shadow_color' => 'eeeeee',
455
+			'submit_hover_bg_color' => 'efefef',
456
+			'submit_hover_color' => '444444',
457
+			'submit_hover_border_color' => 'cccccc',
458
+			'submit_active_bg_color' => 'efefef',
459
+			'submit_active_color' => '444444',
460
+			'submit_active_border_color' => 'cccccc',
461
+
462
+			'border_radius'     => '4px',
463
+			'error_bg'          => 'F2DEDE',
464
+			'error_border'      => 'EBCCD1',
465
+			'error_text'        => 'B94A48',
466
+			'error_font_size'   => '14px',
467
+
468
+			'success_bg_color'  => 'DFF0D8',
469
+			'success_border_color' => 'D6E9C6',
470
+			'success_text_color' => '468847',
471
+			'success_font_size' => '14px',
472
+
473
+			'important_style'   => false,
474
+
475
+			'custom_css'        => '',
476
+		);
477
+	}
478 478
 
479 479
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
480 480
 		return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStyle {
3
-    public $number = false;	// Unique ID number of the current instance.
3
+    public $number = false; // Unique ID number of the current instance.
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
     public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = pow(36, 6);
16
+        $max_slug_value = pow( 36, 6 );
17 17
         $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
18
+        $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
19 19
 
20 20
         $style = array(
21 21
             'post_type'     => FrmStylesController::$post_type,
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44
- 		if ( empty($id) ) {
44
+ 		if ( empty( $id ) ) {
45 45
  		     $new_style = (array) $this->get_new();
46 46
  		     $all_instances[] = $new_style;
47 47
  		}
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         $action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52
- 			$new_instance = stripslashes_deep( (array) $new_instance);
52
+ 			$new_instance = stripslashes_deep( (array) $new_instance );
53 53
  			$this->id = $new_instance['ID'];
54
- 			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55
-				$all_instances[ $number ] = $new_instance;
54
+ 			if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
55
+				$all_instances[$number] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
57
+ 			    if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) {
58 58
  			        // this style was set to default, so remove default setting on previous default style
59 59
  			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
60
+ 			        $action_ids[] = $this->save( $new_instance );
61 61
  			    }
62 62
 
63 63
  			    // don't continue if not saving this style
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+            $new_instance['post_status'] = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
73
+            if ( empty( $id ) ) {
74 74
                 $new_instance['post_name'] = $new_instance['post_title'];
75 75
             }
76 76
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
             foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
81 81
                     //if is a color
82
-					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
83
-				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
84
-					$new_instance['post_content'][ $setting ] = 0;
82
+					$new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] );
83
+				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) {
84
+					$new_instance['post_content'][$setting] = 0;
85 85
                 }
86 86
             }
87 87
 
88
-			$all_instances[ $number ] = $new_instance;
88
+			$all_instances[$number] = $new_instance;
89 89
 
90
-            $action_ids[] = $this->save($new_instance);
90
+            $action_ids[] = $this->save( $new_instance );
91 91
 
92 92
  		}
93 93
 
94
- 		$this->save_settings($all_instances);
94
+ 		$this->save_settings( $all_instances );
95 95
 
96 96
  		return $action_ids;
97 97
  	}
@@ -100,30 +100,30 @@  discard block
 block discarded – undo
100 100
      * Create static css file
101 101
      */
102 102
 	public function save_settings( $styles ) {
103
-        $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
103
+        $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
104 104
 
105
-        if ( ! is_file($filename) ) {
105
+        if ( ! is_file( $filename ) ) {
106 106
             return;
107 107
         }
108 108
 
109 109
         $defaults = $this->get_defaults();
110 110
         $uploads = wp_upload_dir();
111
-        $target_path = $uploads['basedir'] .'/formidable';
112
-        $needed_dirs = array( $target_path, $target_path .'/css' );
111
+        $target_path = $uploads['basedir'] . '/formidable';
112
+        $needed_dirs = array( $target_path, $target_path . '/css' );
113 113
         $dirs_exist = true;
114 114
 
115 115
         $saving = true;
116
-        $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
116
+        $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
117 117
 
118 118
         ob_start();
119 119
         $frm_style = $this;
120
-        include($filename);
120
+        include( $filename );
121 121
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
122 122
         ob_end_clean();
123 123
 
124 124
         $access_type = get_filesystem_method();
125 125
         if ( $access_type === 'direct' ) {
126
-        	$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
126
+        	$creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, array() );
127 127
 		} else {
128 128
 			$creds = $this->get_ftp_creds( $access_type );
129 129
 		}
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
             if ( $dirs_exist ) {
139 139
 	        	global $wp_filesystem;
140 140
 
141
-            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
-            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
141
+            	$chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
+            	$chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
143 143
 
144 144
                 // Create the directories if need be:
145 145
             	foreach ( $needed_dirs as $_dir ) {
@@ -149,33 +149,33 @@  discard block
 block discarded – undo
149 149
                     }
150 150
             	}
151 151
 
152
-                $index_path = $target_path .'/index.php';
152
+                $index_path = $target_path . '/index.php';
153 153
                 $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
154 154
 
155 155
                 // only write the file if the folders exist
156 156
                 if ( $dirs_exist ) {
157
-                    $css_file = $target_path .'/css/formidablepro.css';
157
+                    $css_file = $target_path . '/css/formidablepro.css';
158 158
                     $wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159 159
                 }
160 160
             }
161 161
         }
162 162
 
163
-        update_option('frmpro_css', $css);
163
+        update_option( 'frmpro_css', $css );
164 164
 
165
-        delete_transient('frmpro_css');
166
-        set_transient('frmpro_css', $css);
165
+        delete_transient( 'frmpro_css' );
166
+        set_transient( 'frmpro_css', $css );
167 167
 	}
168 168
 
169 169
 	private function get_ftp_creds( $type ) {
170 170
 		$credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) );
171 171
 
172
-		$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname'];
173
-		$credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username'];
174
-		$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : '';
172
+		$credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname'];
173
+		$credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username'];
174
+		$credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : '';
175 175
 
176 176
 		// Check to see if we are setting the public/private keys for ssh
177
-		$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : '';
178
-		$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : '';
177
+		$credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : '';
178
+		$credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : '';
179 179
 
180 180
 		// Sanitize the hostname, Some people might pass in odd-data:
181 181
 		$credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	}
218 218
 
219 219
 	public function destroy( $id ) {
220
-        return wp_delete_post($id);
220
+        return wp_delete_post( $id );
221 221
     }
222 222
 
223 223
     public function get_one() {
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
             return $style;
232 232
         }
233 233
 
234
-        $style = get_post($this->id);
234
+        $style = get_post( $this->id );
235 235
 
236 236
         if ( ! $style ) {
237 237
             return $style;
238 238
         }
239 239
 
240
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
240
+        $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
241 241
 
242 242
         $default_values = $this->get_defaults();
243 243
 
244 244
         // fill default values
245
-        $style->post_content = $this->override_defaults($style->post_content);
246
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
245
+        $style->post_content = $this->override_defaults( $style->post_content );
246
+        $style->post_content = wp_parse_args( $style->post_content, $default_values );
247 247
 
248 248
         return $style;
249 249
     }
@@ -257,21 +257,21 @@  discard block
 block discarded – undo
257 257
 			'order'       => $order,
258 258
         );
259 259
 
260
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
260
+        $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
261 261
 
262
-        if ( empty($temp_styles) ) {
262
+        if ( empty( $temp_styles ) ) {
263 263
             global $wpdb;
264 264
             // make sure there wasn't a conflict with the query
265
-            $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
265
+            $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
266
+            $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
267 267
 
268
-            if ( empty($temp_styles) ) {
268
+            if ( empty( $temp_styles ) ) {
269 269
                 // create a new style if there are none
270 270
          		$new = $this->get_new();
271 271
          		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272 272
          		$new->menu_order = 1;
273
-         		$new = $this->save( (array) $new);
274
-         		$this->update('default');
273
+         		$new = $this->save( (array) $new );
274
+         		$this->update( 'default' );
275 275
 
276 276
                 $post_atts['include'] = $new;
277 277
 
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
                 }
296 296
             }
297 297
 
298
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
298
+            $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
299 299
 
300 300
             // fill default values
301
-            $style->post_content = $this->override_defaults($style->post_content);
302
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
301
+            $style->post_content = $this->override_defaults( $style->post_content );
302
+            $style->post_content = wp_parse_args( $style->post_content, $default_values );
303 303
 
304
-			$styles[ $style->ID ] = $style;
304
+			$styles[$style->ID] = $style;
305 305
         }
306 306
 
307 307
         if ( ! $default_style ) {
308
-            $default_style = reset($styles);
309
-			$styles[ $default_style->ID ]->menu_order = 1;
308
+            $default_style = reset( $styles );
309
+			$styles[$default_style->ID]->menu_order = 1;
310 310
         }
311 311
 
312 312
         return $styles;
313 313
     }
314 314
 
315 315
 	public function get_default_style( $styles = null ) {
316
-        if ( ! isset($styles) ) {
316
+        if ( ! isset( $styles ) ) {
317 317
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
318 318
         }
319 319
 
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
     }
326 326
 
327 327
 	public function override_defaults( $settings ) {
328
-	    if ( ! is_array($settings) ) {
328
+	    if ( ! is_array( $settings ) ) {
329 329
 	        return $settings;
330 330
 	    }
331 331
 
332
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
332
+	    $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
333 333
 
334
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
334
+	    if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
335 335
 	        $settings['form_desc_size'] = $settings['description_font_size'];
336 336
 	        $settings['form_desc_color'] = $settings['description_color'];
337 337
 	        $settings['title_color'] = $settings['label_color'];
338 338
 	    }
339 339
 
340
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
340
+	    if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) {
341 341
 	        $settings['section_color'] = $settings['label_color'];
342 342
 	        $settings['section_border_color'] = $settings['border_color'];
343 343
 	    }
344 344
 
345
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
345
+	    if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) {
346 346
 	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347 347
 	        $settings['submit_hover_color'] = $settings['submit_text_color'];
348 348
 	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
     }
478 478
 
479 479
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
480
-		return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
480
+		return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
481 481
 	}
482 482
 
483 483
 	public static function get_bold_options() {
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +362 added lines, -362 removed lines patch added patch discarded remove patch
@@ -2,199 +2,199 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11
-            $frm_settings = FrmAppHelper::get_settings();
11
+			$frm_settings = FrmAppHelper::get_settings();
12 12
 			add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( $screen_id != 'formidable_page_formidable-entries' || ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( $screen_id != 'formidable_page_formidable-entries' || ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 		unset( $action, $page );
50 50
 
51
-        $screen->add_help_tab( array(
52
-            'id'      => 'formidable-entries-tab',
53
-            'title'   => __( 'Overview', 'formidable' ),
51
+		$screen->add_help_tab( array(
52
+			'id'      => 'formidable-entries-tab',
53
+			'title'   => __( 'Overview', 'formidable' ),
54 54
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
55
-        ));
55
+		));
56 56
 
57
-        $screen->set_help_sidebar(
57
+		$screen->set_help_sidebar(
58 58
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
59 59
 			'<p><a href="http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
60 60
 			'<p><a href="http://formidablepro.com/help-topics/" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
61
-    	);
61
+		);
62 62
 
63
-        return $help;
64
-    }
63
+		return $help;
64
+	}
65 65
 
66 66
 	public static function manage_columns( $columns ) {
67
-        global $frm_vars, $wpdb;
67
+		global $frm_vars, $wpdb;
68 68
 		$form_id = FrmForm::get_current_form_id();
69 69
 
70
-        $columns[ $form_id .'_id' ] = 'ID';
70
+		$columns[ $form_id .'_id' ] = 'ID';
71 71
 		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
72 72
 
73
-        if ( ! $form_id ) {
74
-            return $columns;
75
-        }
73
+		if ( ! $form_id ) {
74
+			return $columns;
75
+		}
76 76
 
77
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
77
+		$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78 78
 
79
-        foreach ( $form_cols as $form_col ) {
79
+		foreach ( $form_cols as $form_col ) {
80 80
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
81
-                continue;
82
-            }
81
+				continue;
82
+			}
83 83
 
84
-            if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
84
+			if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
85 85
 				$sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
86 86
 
87
-                if ( $sub_form_cols ) {
88
-                    foreach ( $sub_form_cols as $k => $sub_form_col ) {
87
+				if ( $sub_form_cols ) {
88
+					foreach ( $sub_form_cols as $k => $sub_form_col ) {
89 89
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
90
-                            unset( $sub_form_cols[ $k ] );
91
-                            continue;
92
-                        }
90
+							unset( $sub_form_cols[ $k ] );
91
+							continue;
92
+						}
93 93
 						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
94
-                        unset($sub_form_col);
95
-                    }
96
-                }
97
-                unset($sub_form_cols);
98
-            } else {
99
-                $col_id = $form_col->field_key;
100
-                if ( $form_col->form_id != $form_id ) {
101
-                    $col_id .= '-_-form'. $form_col->form_id;
102
-                }
103
-
104
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
105
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
106
-                }
107
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
-            }
109
-        }
110
-
111
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
112
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
113
-        $columns[ $form_id .'_ip' ] = 'IP';
114
-
115
-        $frm_vars['cols'] = $columns;
94
+						unset($sub_form_col);
95
+					}
96
+				}
97
+				unset($sub_form_cols);
98
+			} else {
99
+				$col_id = $form_col->field_key;
100
+				if ( $form_col->form_id != $form_id ) {
101
+					$col_id .= '-_-form'. $form_col->form_id;
102
+				}
103
+
104
+				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
105
+					$columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
106
+				}
107
+				$columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
+			}
109
+		}
110
+
111
+		$columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
112
+		$columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
113
+		$columns[ $form_id .'_ip' ] = 'IP';
114
+
115
+		$frm_vars['cols'] = $columns;
116 116
 
117 117
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
118 118
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
119 119
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
120
-        }
120
+		}
121 121
 
122
-        return $columns;
123
-    }
122
+		return $columns;
123
+	}
124 124
 
125 125
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
126
-        $frm_settings = FrmAppHelper::get_settings();
127
-        if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
128
-            return $check;
129
-        }
126
+		$frm_settings = FrmAppHelper::get_settings();
127
+		if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
128
+			return $check;
129
+		}
130 130
 
131 131
 		if ( empty( $prev_value ) ) {
132
-            		$prev_value = get_metadata('user', $object_id, $meta_key, true);
133
-        }
132
+					$prev_value = get_metadata('user', $object_id, $meta_key, true);
133
+		}
134 134
 
135
-        global $frm_vars;
136
-        //add a check so we don't create a loop
137
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
135
+		global $frm_vars;
136
+		//add a check so we don't create a loop
137
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
138 138
 
139
-        return $check;
140
-    }
139
+		return $check;
140
+	}
141 141
 
142
-    //add hidden columns back from other forms
142
+	//add hidden columns back from other forms
143 143
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
144
-        $frm_settings = FrmAppHelper::get_settings();
145
-
146
-        $sanitized = sanitize_title($frm_settings->menu);
147
-        if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
148
-            return;
149
-        }
150
-
151
-        global $frm_vars;
152
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
153
-            return; //don't continue if there's no previous value
154
-        }
155
-
156
-        foreach ( $meta_value as $mk => $mv ) {
157
-            //remove blank values
158
-            if ( empty( $mv )  ) {
159
-                unset( $meta_value[ $mk ] );
160
-            }
161
-        }
162
-
163
-        $cur_form_prefix = reset($meta_value);
164
-        $cur_form_prefix = explode('_', $cur_form_prefix);
165
-        $cur_form_prefix = $cur_form_prefix[0];
166
-        $save = false;
167
-
168
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
144
+		$frm_settings = FrmAppHelper::get_settings();
145
+
146
+		$sanitized = sanitize_title($frm_settings->menu);
147
+		if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
148
+			return;
149
+		}
150
+
151
+		global $frm_vars;
152
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
153
+			return; //don't continue if there's no previous value
154
+		}
155
+
156
+		foreach ( $meta_value as $mk => $mv ) {
157
+			//remove blank values
158
+			if ( empty( $mv )  ) {
159
+				unset( $meta_value[ $mk ] );
160
+			}
161
+		}
162
+
163
+		$cur_form_prefix = reset($meta_value);
164
+		$cur_form_prefix = explode('_', $cur_form_prefix);
165
+		$cur_form_prefix = $cur_form_prefix[0];
166
+		$save = false;
167
+
168
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
169 169
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
170
-                //don't add blank cols or process included cols
171
-                continue;
172
-            }
170
+				//don't add blank cols or process included cols
171
+				continue;
172
+			}
173 173
 
174 174
 			$form_prefix = explode( '_', $prev_hidden );
175
-            $form_prefix = $form_prefix[0];
176
-            if ( $form_prefix == $cur_form_prefix ) {
177
-                //don't add back columns that are meant to be hidden
178
-                continue;
179
-            }
175
+			$form_prefix = $form_prefix[0];
176
+			if ( $form_prefix == $cur_form_prefix ) {
177
+				//don't add back columns that are meant to be hidden
178
+				continue;
179
+			}
180 180
 
181
-            $meta_value[] = $prev_hidden;
182
-            $save = true;
183
-            unset($form_prefix);
184
-        }
181
+			$meta_value[] = $prev_hidden;
182
+			$save = true;
183
+			unset($form_prefix);
184
+		}
185 185
 
186 186
 		if ( $save ) {
187
-            $user = wp_get_current_user();
188
-            update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
189
-        }
190
-    }
187
+			$user = wp_get_current_user();
188
+			update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
189
+		}
190
+	}
191 191
 
192 192
 	public static function save_per_page( $save, $option, $value ) {
193
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
194
-            $save = (int) $value;
195
-        }
196
-        return $save;
197
-    }
193
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
194
+			$save = (int) $value;
195
+		}
196
+		return $save;
197
+	}
198 198
 
199 199
 	public static function sortable_columns() {
200 200
 		$form_id = FrmForm::get_current_form_id();
@@ -220,226 +220,226 @@  discard block
 block discarded – undo
220 220
 	}
221 221
 
222 222
 	public static function hidden_columns( $result ) {
223
-        global $frm_vars;
223
+		global $frm_vars;
224 224
 
225 225
 		$form_id = FrmForm::get_current_form_id();
226 226
 
227
-        $return = false;
228
-        foreach ( (array) $result as $r ) {
229
-            if ( ! empty( $r ) ) {
230
-                $form_prefix = explode( '_', $r );
231
-                $form_prefix = $form_prefix[0];
227
+		$return = false;
228
+		foreach ( (array) $result as $r ) {
229
+			if ( ! empty( $r ) ) {
230
+				$form_prefix = explode( '_', $r );
231
+				$form_prefix = $form_prefix[0];
232 232
 
233
-                if ( (int) $form_prefix == (int) $form_id ) {
234
-                    $return = true;
235
-                    break;
236
-                }
233
+				if ( (int) $form_prefix == (int) $form_id ) {
234
+					$return = true;
235
+					break;
236
+				}
237 237
 
238
-                unset($form_prefix);
239
-            }
240
-        }
238
+				unset($form_prefix);
239
+			}
240
+		}
241 241
 
242
-        if ( $return ) {
242
+		if ( $return ) {
243 243
 			return $result;
244 244
 		}
245 245
 
246
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
247
-        $max_columns = 8;
248
-        if ( $i <= $max_columns ) {
246
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
247
+		$max_columns = 8;
248
+		if ( $i <= $max_columns ) {
249 249
 			return $result;
250 250
 		}
251 251
 
252
-        global $frm_vars;
253
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
254
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
255
-        }
252
+		global $frm_vars;
253
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
254
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
255
+		}
256 256
 
257
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
258
-            $result = $frm_vars['current_form']->options['hidden_cols'];
259
-        } else {
260
-            $cols = $frm_vars['cols'];
261
-            $cols = array_reverse($cols, true);
257
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
258
+			$result = $frm_vars['current_form']->options['hidden_cols'];
259
+		} else {
260
+			$cols = $frm_vars['cols'];
261
+			$cols = array_reverse($cols, true);
262 262
 
263
-            $result[] = $form_id .'_id';
264
-            $i--;
263
+			$result[] = $form_id .'_id';
264
+			$i--;
265 265
 
266
-            $result[] = $form_id .'_item_key';
267
-            $i--;
266
+			$result[] = $form_id .'_item_key';
267
+			$i--;
268 268
 
269 269
 			foreach ( $cols as $col_key => $col ) {
270
-                if ( $i > $max_columns ) {
270
+				if ( $i > $max_columns ) {
271 271
 					$result[] = $col_key;
272 272
 				}
273
-                //remove some columns by default
274
-                $i--;
275
-                unset($col_key, $col);
276
-            }
277
-        }
273
+				//remove some columns by default
274
+				$i--;
275
+				unset($col_key, $col);
276
+			}
277
+		}
278 278
 
279
-        return $result;
280
-    }
279
+		return $result;
280
+	}
281 281
 
282 282
 	public static function display_list( $message = '', $errors = array() ) {
283
-        global $wpdb, $frm_vars;
283
+		global $wpdb, $frm_vars;
284 284
 
285 285
 		$form = FrmForm::get_current_form();
286 286
 		$params = FrmForm::get_admin_params( $form );
287 287
 
288
-        if ( $form ) {
289
-            $params['form'] = $form->id;
290
-            $frm_vars['current_form'] = $form;
288
+		if ( $form ) {
289
+			$params['form'] = $form->id;
290
+			$frm_vars['current_form'] = $form;
291 291
 
292
-	        if ( 'trash' == $form->status ) {
293
-	            $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
294
-	            $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
295
-	            $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
296
-	            unset( $time_to_delete, $delete_timestamp );
297
-	        }
292
+			if ( 'trash' == $form->status ) {
293
+				$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
294
+				$time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
295
+				$errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
296
+				unset( $time_to_delete, $delete_timestamp );
297
+			}
298 298
 		}
299 299
 
300
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
300
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
301 301
 
302
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
302
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
303 303
 
304
-        $pagenum = $wp_list_table->get_pagenum();
304
+		$pagenum = $wp_list_table->get_pagenum();
305 305
 
306
-        $wp_list_table->prepare_items();
306
+		$wp_list_table->prepare_items();
307 307
 
308
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
309
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
308
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
309
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
310 310
 			$url = add_query_arg( 'paged', $total_pages );
311
-            if ( headers_sent() ) {
312
-                echo FrmAppHelper::js_redirect($url);
313
-            } else {
314
-                wp_redirect( esc_url_raw( $url ) );
315
-            }
316
-            die();
317
-        }
318
-
319
-        if ( empty($message) && isset($_GET['import-message']) ) {
320
-            $message = __( 'Your import is complete', 'formidable' );
321
-        }
322
-
323
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
324
-    }
325
-
326
-    /* Back End CRUD */
311
+			if ( headers_sent() ) {
312
+				echo FrmAppHelper::js_redirect($url);
313
+			} else {
314
+				wp_redirect( esc_url_raw( $url ) );
315
+			}
316
+			die();
317
+		}
318
+
319
+		if ( empty($message) && isset($_GET['import-message']) ) {
320
+			$message = __( 'Your import is complete', 'formidable' );
321
+		}
322
+
323
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
324
+	}
325
+
326
+	/* Back End CRUD */
327 327
 	public static function show( $id = 0 ) {
328
-        FrmAppHelper::permission_check('frm_view_entries');
328
+		FrmAppHelper::permission_check('frm_view_entries');
329 329
 
330
-        if ( ! $id ) {
330
+		if ( ! $id ) {
331 331
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
332 332
 
333
-            if ( ! $id ) {
333
+			if ( ! $id ) {
334 334
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
335
-            }
336
-        }
335
+			}
336
+		}
337 337
 
338
-        $entry = FrmEntry::getOne($id, true);
338
+		$entry = FrmEntry::getOne($id, true);
339 339
 
340
-        $data = maybe_unserialize($entry->description);
340
+		$data = maybe_unserialize($entry->description);
341 341
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
342 342
 			$data = array( 'referrer' => $data );
343 343
 		}
344 344
 
345 345
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
346
-        $to_emails = array();
346
+		$to_emails = array();
347 347
 
348
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
349
-    }
348
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
349
+	}
350 350
 
351
-    public static function destroy() {
352
-        FrmAppHelper::permission_check('frm_delete_entries');
351
+	public static function destroy() {
352
+		FrmAppHelper::permission_check('frm_delete_entries');
353 353
 
354 354
 		$params = FrmForm::get_admin_params();
355 355
 
356
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
357
-            //unlink entry from post
358
-            global $wpdb;
356
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
357
+			//unlink entry from post
358
+			global $wpdb;
359 359
 			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
360
-        }
360
+		}
361 361
 
362
-        $message = '';
363
-        if ( FrmEntry::destroy( $params['id'] ) ) {
364
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
365
-        }
362
+		$message = '';
363
+		if ( FrmEntry::destroy( $params['id'] ) ) {
364
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
365
+		}
366 366
 
367
-        self::display_list( $message );
368
-    }
367
+		self::display_list( $message );
368
+	}
369 369
 
370
-    public static function destroy_all() {
371
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
372
-            $frm_settings = FrmAppHelper::get_settings();
373
-            wp_die( $frm_settings->admin_permission );
374
-        }
370
+	public static function destroy_all() {
371
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
372
+			$frm_settings = FrmAppHelper::get_settings();
373
+			wp_die( $frm_settings->admin_permission );
374
+		}
375 375
 
376
-        global $wpdb;
376
+		global $wpdb;
377 377
 		$params = FrmForm::get_admin_params();
378
-        $message = '';
379
-        $errors = array();
380
-        $form_id = (int) $params['form'];
378
+		$message = '';
379
+		$errors = array();
380
+		$form_id = (int) $params['form'];
381 381
 
382
-        if ( $form_id ) {
383
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
382
+		if ( $form_id ) {
383
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
384 384
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
385 385
 
386
-            if ( $action ) {
387
-                // this action takes a while, so only trigger it if there are posts to delete
388
-                foreach ( $entry_ids as $entry_id ) {
389
-                    do_action( 'frm_before_destroy_entry', $entry_id );
390
-                    unset( $entry_id );
391
-                }
392
-            }
393
-
394
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
395
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
396
-            if ( $results ) {
397
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
398
-            }
399
-        } else {
400
-            $errors = __( 'No entries were specified', 'formidable' );
401
-        }
402
-
403
-        self::display_list( $message, $errors );
404
-    }
405
-
406
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
407
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
408
-        return FrmFormsController::show_form( $id, $key, $title, $description );
409
-    }
410
-
411
-    public static function get_form( $filename, $form, $title, $description ) {
412
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
413
-        return FrmFormsController::get_form( $form, $title, $description );
414
-    }
415
-
416
-    public static function process_entry( $errors = '', $ajax = false ) {
386
+			if ( $action ) {
387
+				// this action takes a while, so only trigger it if there are posts to delete
388
+				foreach ( $entry_ids as $entry_id ) {
389
+					do_action( 'frm_before_destroy_entry', $entry_id );
390
+					unset( $entry_id );
391
+				}
392
+			}
393
+
394
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
395
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
396
+			if ( $results ) {
397
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
398
+			}
399
+		} else {
400
+			$errors = __( 'No entries were specified', 'formidable' );
401
+		}
402
+
403
+		self::display_list( $message, $errors );
404
+	}
405
+
406
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
407
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
408
+		return FrmFormsController::show_form( $id, $key, $title, $description );
409
+	}
410
+
411
+	public static function get_form( $filename, $form, $title, $description ) {
412
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
413
+		return FrmFormsController::get_form( $form, $title, $description );
414
+	}
415
+
416
+	public static function process_entry( $errors = '', $ajax = false ) {
417 417
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
418 418
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
419
-            return;
420
-        }
419
+			return;
420
+		}
421 421
 
422
-        global $frm_vars;
422
+		global $frm_vars;
423 423
 
424 424
 		$form = FrmForm::getOne( $form_id );
425
-        if ( ! $form ) {
426
-            return;
427
-        }
425
+		if ( ! $form ) {
426
+			return;
427
+		}
428 428
 
429 429
 		$params = FrmForm::get_params( $form );
430 430
 
431
-        if ( ! isset( $frm_vars['form_params'] ) ) {
432
-            $frm_vars['form_params'] = array();
433
-        }
431
+		if ( ! isset( $frm_vars['form_params'] ) ) {
432
+			$frm_vars['form_params'] = array();
433
+		}
434 434
 		$frm_vars['form_params'][ $form->id ] = $params;
435 435
 
436 436
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
437
-            return;
438
-        }
437
+			return;
438
+		}
439 439
 
440
-        if ( $errors == '' ) {
440
+		if ( $errors == '' ) {
441 441
 			$errors = FrmEntryValidate::validate( $_POST );
442
-        }
442
+		}
443 443
 
444 444
 		/**
445 445
 		 * Use this filter to add trigger actions and add errors after
@@ -450,102 +450,102 @@  discard block
 block discarded – undo
450 450
 
451 451
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
452 452
 
453
-        if ( empty( $errors ) ) {
453
+		if ( empty( $errors ) ) {
454 454
 			$_POST['frm_skip_cookie'] = 1;
455
-            if ( $params['action'] == 'create' ) {
455
+			if ( $params['action'] == 'create' ) {
456 456
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
457 457
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
458
-                }
459
-            }
458
+				}
459
+			}
460 460
 
461
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
461
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
462 462
 			unset( $_POST['frm_skip_cookie'] );
463
-        }
464
-    }
465
-
466
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
467
-        self::_delete_entry( $atts['id'], $form );
468
-        return $url;
469
-    }
470
-
471
-    //Delete entry if not redirected
472
-    public static function delete_entry_after_save( $atts ) {
473
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
474
-    }
475
-
476
-    private static function _delete_entry( $entry_id, $form ) {
477
-        if ( ! $form ) {
478
-            return;
479
-        }
480
-
481
-        $form->options = maybe_unserialize( $form->options );
482
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
483
-            FrmEntry::destroy( $entry_id );
484
-        }
485
-    }
463
+		}
464
+	}
465
+
466
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
467
+		self::_delete_entry( $atts['id'], $form );
468
+		return $url;
469
+	}
470
+
471
+	//Delete entry if not redirected
472
+	public static function delete_entry_after_save( $atts ) {
473
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
474
+	}
475
+
476
+	private static function _delete_entry( $entry_id, $form ) {
477
+		if ( ! $form ) {
478
+			return;
479
+		}
480
+
481
+		$form->options = maybe_unserialize( $form->options );
482
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
483
+			FrmEntry::destroy( $entry_id );
484
+		}
485
+	}
486 486
 
487 487
 	public static function show_entry_shortcode( $atts ) {
488 488
 		return FrmEntryFormat::show_entry( $atts );
489 489
 	}
490 490
 
491
-    public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
492
-        $field = FrmField::getOne($meta->field_id);
493
-        if ( ! $field ) {
494
-            return $value;
495
-        }
491
+	public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
492
+		$field = FrmField::getOne($meta->field_id);
493
+		if ( ! $field ) {
494
+			return $value;
495
+		}
496 496
 
497
-        $value = self::filter_display_value($value, $field, $atts);
498
-        return $value;
499
-    }
497
+		$value = self::filter_display_value($value, $field, $atts);
498
+		return $value;
499
+	}
500 500
 
501 501
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
502
-        $plain_text = add_filter('frm_plain_text_email', true);
502
+		$plain_text = add_filter('frm_plain_text_email', true);
503 503
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
504 504
 
505
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
506
-            return $value;
507
-        }
505
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
506
+			return $value;
507
+		}
508 508
 
509
-        return self::filter_display_value($value, $field, $atts);
510
-    }
509
+		return self::filter_display_value($value, $field, $atts);
510
+	}
511 511
 
512
-    public static function &filter_display_value( $value, $field, $atts = array() ) {
513
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
512
+	public static function &filter_display_value( $value, $field, $atts = array() ) {
513
+		$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
514 514
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
515
-            return $value;
516
-        }
517
-
518
-        $f_values = $f_labels = array();
519
-
520
-        foreach ( $field->options as $opt_key => $opt ) {
521
-            if ( ! is_array($opt) ) {
522
-                continue;
523
-            }
524
-
525
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
526
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
527
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
528
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
529
-            }
530
-            unset($opt_key, $opt);
531
-        }
532
-
533
-        if ( ! empty($f_values) ) {
534
-            foreach ( (array) $value as $v_key => $val ) {
535
-                if ( in_array($val, $f_values) ) {
536
-                    $opt = array_search($val, $f_values);
537
-                    if ( is_array($value) ) {
538
-                        $value[ $v_key ] = $f_labels[ $opt ];
539
-                    } else {
540
-                        $value = $f_labels[ $opt ];
541
-                    }
542
-                }
543
-                unset($v_key, $val);
544
-            }
545
-        }
546
-
547
-        return $value;
548
-    }
515
+			return $value;
516
+		}
517
+
518
+		$f_values = $f_labels = array();
519
+
520
+		foreach ( $field->options as $opt_key => $opt ) {
521
+			if ( ! is_array($opt) ) {
522
+				continue;
523
+			}
524
+
525
+			$f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
526
+			$f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
527
+			if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
528
+				unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
529
+			}
530
+			unset($opt_key, $opt);
531
+		}
532
+
533
+		if ( ! empty($f_values) ) {
534
+			foreach ( (array) $value as $v_key => $val ) {
535
+				if ( in_array($val, $f_values) ) {
536
+					$opt = array_search($val, $f_values);
537
+					if ( is_array($value) ) {
538
+						$value[ $v_key ] = $f_labels[ $opt ];
539
+					} else {
540
+						$value = $f_labels[ $opt ];
541
+					}
542
+				}
543
+				unset($v_key, $val);
544
+			}
545
+		}
546
+
547
+		return $value;
548
+	}
549 549
 
550 550
 	public static function get_params( $form = null ) {
551 551
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -553,13 +553,13 @@  discard block
 block discarded – undo
553 553
 	}
554 554
 
555 555
 	public static function entry_sidebar( $entry ) {
556
-        $data = maybe_unserialize($entry->description);
557
-        $date_format = get_option('date_format');
558
-        $time_format = get_option('time_format');
556
+		$data = maybe_unserialize($entry->description);
557
+		$date_format = get_option('date_format');
558
+		$time_format = get_option('time_format');
559 559
 		if ( isset( $data['browser'] ) ) {
560 560
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
561 561
 		}
562 562
 
563
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
564
-    }
563
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
564
+	}
565 565
 }
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
             $frm_settings = FrmAppHelper::get_settings();
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
         $screen->add_help_tab( array(
52 52
             'id'      => 'formidable-entries-tab',
53 53
             'title'   => __( 'Overview', 'formidable' ),
54
-			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
55
-        ));
54
+			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
55
+        ) );
56 56
 
57 57
         $screen->set_help_sidebar(
58 58
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
         global $frm_vars, $wpdb;
68 68
 		$form_id = FrmForm::get_current_form_id();
69 69
 
70
-        $columns[ $form_id .'_id' ] = 'ID';
71
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
70
+        $columns[$form_id . '_id'] = 'ID';
71
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
72 72
 
73 73
         if ( ! $form_id ) {
74 74
             return $columns;
75 75
         }
76 76
 
77
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
77
+        $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
78 78
 
79 79
         foreach ( $form_cols as $form_col ) {
80 80
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
@@ -87,30 +87,30 @@  discard block
 block discarded – undo
87 87
                 if ( $sub_form_cols ) {
88 88
                     foreach ( $sub_form_cols as $k => $sub_form_col ) {
89 89
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
90
-                            unset( $sub_form_cols[ $k ] );
90
+                            unset( $sub_form_cols[$k] );
91 91
                             continue;
92 92
                         }
93
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
94
-                        unset($sub_form_col);
93
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
94
+                        unset( $sub_form_col );
95 95
                     }
96 96
                 }
97
-                unset($sub_form_cols);
97
+                unset( $sub_form_cols );
98 98
             } else {
99 99
                 $col_id = $form_col->field_key;
100 100
                 if ( $form_col->form_id != $form_id ) {
101
-                    $col_id .= '-_-form'. $form_col->form_id;
101
+                    $col_id .= '-_-form' . $form_col->form_id;
102 102
                 }
103 103
 
104
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
105
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
104
+                if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) {
105
+                    $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
106 106
                 }
107
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
+                $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
108 108
             }
109 109
         }
110 110
 
111
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
112
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
113
-        $columns[ $form_id .'_ip' ] = 'IP';
111
+        $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
112
+        $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
113
+        $columns[$form_id . '_ip'] = 'IP';
114 114
 
115 115
         $frm_vars['cols'] = $columns;
116 116
 
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 
125 125
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
126 126
         $frm_settings = FrmAppHelper::get_settings();
127
-        if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
127
+        if ( $meta_key != 'manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
128 128
             return $check;
129 129
         }
130 130
 
131 131
 		if ( empty( $prev_value ) ) {
132
-            		$prev_value = get_metadata('user', $object_id, $meta_key, true);
132
+            		$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
133 133
         }
134 134
 
135 135
         global $frm_vars;
136 136
         //add a check so we don't create a loop
137
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
137
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
138 138
 
139 139
         return $check;
140 140
     }
@@ -143,25 +143,25 @@  discard block
 block discarded – undo
143 143
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
144 144
         $frm_settings = FrmAppHelper::get_settings();
145 145
 
146
-        $sanitized = sanitize_title($frm_settings->menu);
147
-        if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
146
+        $sanitized = sanitize_title( $frm_settings->menu );
147
+        if ( $meta_key != 'manage' . $sanitized . '_page_formidable-entriescolumnshidden' ) {
148 148
             return;
149 149
         }
150 150
 
151 151
         global $frm_vars;
152
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
152
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
153 153
             return; //don't continue if there's no previous value
154 154
         }
155 155
 
156 156
         foreach ( $meta_value as $mk => $mv ) {
157 157
             //remove blank values
158
-            if ( empty( $mv )  ) {
159
-                unset( $meta_value[ $mk ] );
158
+            if ( empty( $mv ) ) {
159
+                unset( $meta_value[$mk] );
160 160
             }
161 161
         }
162 162
 
163
-        $cur_form_prefix = reset($meta_value);
164
-        $cur_form_prefix = explode('_', $cur_form_prefix);
163
+        $cur_form_prefix = reset( $meta_value );
164
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
165 165
         $cur_form_prefix = $cur_form_prefix[0];
166 166
         $save = false;
167 167
 
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 
181 181
             $meta_value[] = $prev_hidden;
182 182
             $save = true;
183
-            unset($form_prefix);
183
+            unset( $form_prefix );
184 184
         }
185 185
 
186 186
 		if ( $save ) {
187 187
             $user = wp_get_current_user();
188
-            update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
188
+            update_user_option( $user->ID, 'manage' . $sanitized . '_page_formidable-entriescolumnshidden', $meta_value, true );
189 189
         }
190 190
     }
191 191
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		foreach ( $fields as $field ) {
213 213
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
214 214
 				// Can't sort on checkboxes because they are stored serialized, or post fields
215
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
215
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
216 216
 			}
217 217
 		}
218 218
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                     break;
236 236
                 }
237 237
 
238
-                unset($form_prefix);
238
+                unset( $form_prefix );
239 239
             }
240 240
         }
241 241
 
@@ -243,36 +243,36 @@  discard block
 block discarded – undo
243 243
 			return $result;
244 244
 		}
245 245
 
246
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
246
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
247 247
         $max_columns = 8;
248 248
         if ( $i <= $max_columns ) {
249 249
 			return $result;
250 250
 		}
251 251
 
252 252
         global $frm_vars;
253
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
254
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
253
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
254
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
255 255
         }
256 256
 
257
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
257
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) {
258 258
             $result = $frm_vars['current_form']->options['hidden_cols'];
259 259
         } else {
260 260
             $cols = $frm_vars['cols'];
261
-            $cols = array_reverse($cols, true);
261
+            $cols = array_reverse( $cols, true );
262 262
 
263
-            $result[] = $form_id .'_id';
264
-            $i--;
263
+            $result[] = $form_id . '_id';
264
+            $i --;
265 265
 
266
-            $result[] = $form_id .'_item_key';
267
-            $i--;
266
+            $result[] = $form_id . '_item_key';
267
+            $i --;
268 268
 
269 269
 			foreach ( $cols as $col_key => $col ) {
270 270
                 if ( $i > $max_columns ) {
271 271
 					$result[] = $col_key;
272 272
 				}
273 273
                 //remove some columns by default
274
-                $i--;
275
-                unset($col_key, $col);
274
+                $i --;
275
+                unset( $col_key, $col );
276 276
             }
277 277
         }
278 278
 
@@ -309,23 +309,23 @@  discard block
 block discarded – undo
309 309
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
310 310
 			$url = add_query_arg( 'paged', $total_pages );
311 311
             if ( headers_sent() ) {
312
-                echo FrmAppHelper::js_redirect($url);
312
+                echo FrmAppHelper::js_redirect( $url );
313 313
             } else {
314 314
                 wp_redirect( esc_url_raw( $url ) );
315 315
             }
316 316
             die();
317 317
         }
318 318
 
319
-        if ( empty($message) && isset($_GET['import-message']) ) {
319
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
320 320
             $message = __( 'Your import is complete', 'formidable' );
321 321
         }
322 322
 
323
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
323
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
324 324
     }
325 325
 
326 326
     /* Back End CRUD */
327 327
 	public static function show( $id = 0 ) {
328
-        FrmAppHelper::permission_check('frm_view_entries');
328
+        FrmAppHelper::permission_check( 'frm_view_entries' );
329 329
 
330 330
         if ( ! $id ) {
331 331
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
             }
336 336
         }
337 337
 
338
-        $entry = FrmEntry::getOne($id, true);
338
+        $entry = FrmEntry::getOne( $id, true );
339 339
 
340
-        $data = maybe_unserialize($entry->description);
340
+        $data = maybe_unserialize( $entry->description );
341 341
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
342 342
 			$data = array( 'referrer' => $data );
343 343
 		}
@@ -345,18 +345,18 @@  discard block
 block discarded – undo
345 345
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
346 346
         $to_emails = array();
347 347
 
348
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
348
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
349 349
     }
350 350
 
351 351
     public static function destroy() {
352
-        FrmAppHelper::permission_check('frm_delete_entries');
352
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
353 353
 
354 354
 		$params = FrmForm::get_admin_params();
355 355
 
356
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
356
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
357 357
             //unlink entry from post
358 358
             global $wpdb;
359
-			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
359
+			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
360 360
         }
361 361
 
362 362
         $message = '';
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
         if ( ! isset( $frm_vars['form_params'] ) ) {
432 432
             $frm_vars['form_params'] = array();
433 433
         }
434
-		$frm_vars['form_params'][ $form->id ] = $params;
434
+		$frm_vars['form_params'][$form->id] = $params;
435 435
 
436
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
436
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
437 437
             return;
438 438
         }
439 439
 
@@ -448,13 +448,13 @@  discard block
 block discarded – undo
448 448
 		 */
449 449
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
450 450
 
451
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
451
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
452 452
 
453 453
         if ( empty( $errors ) ) {
454 454
 			$_POST['frm_skip_cookie'] = 1;
455 455
             if ( $params['action'] == 'create' ) {
456
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
457
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
456
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
457
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
458 458
                 }
459 459
             }
460 460
 
@@ -489,28 +489,28 @@  discard block
 block discarded – undo
489 489
 	}
490 490
 
491 491
     public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
492
-        $field = FrmField::getOne($meta->field_id);
492
+        $field = FrmField::getOne( $meta->field_id );
493 493
         if ( ! $field ) {
494 494
             return $value;
495 495
         }
496 496
 
497
-        $value = self::filter_display_value($value, $field, $atts);
497
+        $value = self::filter_display_value( $value, $field, $atts );
498 498
         return $value;
499 499
     }
500 500
 
501 501
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
502
-        $plain_text = add_filter('frm_plain_text_email', true);
502
+        $plain_text = add_filter( 'frm_plain_text_email', true );
503 503
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
504 504
 
505
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
505
+        if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) {
506 506
             return $value;
507 507
         }
508 508
 
509
-        return self::filter_display_value($value, $field, $atts);
509
+        return self::filter_display_value( $value, $field, $atts );
510 510
     }
511 511
 
512 512
     public static function &filter_display_value( $value, $field, $atts = array() ) {
513
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
513
+        $saved_value = ( isset( $atts['saved_value'] ) && $atts['saved_value'] ) ? true : false;
514 514
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
515 515
             return $value;
516 516
         }
@@ -518,29 +518,29 @@  discard block
 block discarded – undo
518 518
         $f_values = $f_labels = array();
519 519
 
520 520
         foreach ( $field->options as $opt_key => $opt ) {
521
-            if ( ! is_array($opt) ) {
521
+            if ( ! is_array( $opt ) ) {
522 522
                 continue;
523 523
             }
524 524
 
525
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
526
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
527
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
528
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
525
+            $f_labels[$opt_key] = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
526
+            $f_values[$opt_key] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[$opt_key];
527
+            if ( $f_labels[$opt_key] == $f_values[$opt_key] ) {
528
+                unset( $f_values[$opt_key], $f_labels[$opt_key] );
529 529
             }
530
-            unset($opt_key, $opt);
530
+            unset( $opt_key, $opt );
531 531
         }
532 532
 
533
-        if ( ! empty($f_values) ) {
533
+        if ( ! empty( $f_values ) ) {
534 534
             foreach ( (array) $value as $v_key => $val ) {
535
-                if ( in_array($val, $f_values) ) {
536
-                    $opt = array_search($val, $f_values);
537
-                    if ( is_array($value) ) {
538
-                        $value[ $v_key ] = $f_labels[ $opt ];
535
+                if ( in_array( $val, $f_values ) ) {
536
+                    $opt = array_search( $val, $f_values );
537
+                    if ( is_array( $value ) ) {
538
+                        $value[$v_key] = $f_labels[$opt];
539 539
                     } else {
540
-                        $value = $f_labels[ $opt ];
540
+                        $value = $f_labels[$opt];
541 541
                     }
542 542
                 }
543
-                unset($v_key, $val);
543
+                unset( $v_key, $val );
544 544
             }
545 545
         }
546 546
 
@@ -553,13 +553,13 @@  discard block
 block discarded – undo
553 553
 	}
554 554
 
555 555
 	public static function entry_sidebar( $entry ) {
556
-        $data = maybe_unserialize($entry->description);
557
-        $date_format = get_option('date_format');
558
-        $time_format = get_option('time_format');
556
+        $data = maybe_unserialize( $entry->description );
557
+        $date_format = get_option( 'date_format' );
558
+        $time_format = get_option( 'time_format' );
559 559
 		if ( isset( $data['browser'] ) ) {
560 560
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
561 561
 		}
562 562
 
563
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
563
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
564 564
     }
565 565
 }
Please login to merge, or discard this patch.
classes/controllers/FrmFormActionsController.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -1,109 +1,109 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmFormActionsController {
4
-    public static $action_post_type = 'frm_form_actions';
5
-    public static $registered_actions;
6
-
7
-    public static function register_post_types() {
8
-        register_post_type( self::$action_post_type, array(
9
-            'label' => __( 'Form Actions', 'formidable' ),
10
-            'description' => '',
11
-            'public' => false,
12
-            'show_ui' => false,
13
-            'exclude_from_search' => true,
14
-            'show_in_nav_menus' => false,
15
-            'show_in_menu' => true,
16
-            'capability_type' => 'page',
17
-            'supports' => array(
4
+	public static $action_post_type = 'frm_form_actions';
5
+	public static $registered_actions;
6
+
7
+	public static function register_post_types() {
8
+		register_post_type( self::$action_post_type, array(
9
+			'label' => __( 'Form Actions', 'formidable' ),
10
+			'description' => '',
11
+			'public' => false,
12
+			'show_ui' => false,
13
+			'exclude_from_search' => true,
14
+			'show_in_nav_menus' => false,
15
+			'show_in_menu' => true,
16
+			'capability_type' => 'page',
17
+			'supports' => array(
18 18
 				'title', 'editor', 'excerpt', 'custom-fields',
19 19
 				'page-attributes',
20
-            ),
21
-            'has_archive' => false,
22
-        ) );
23
-
24
-        /**
25
-         * post_content: json settings
26
-         * menu_order: form id
27
-         * post_excerpt: action type
28
-         */
29
-
30
-        self::actions_init();
31
-    }
32
-
33
-    public static function actions_init() {
34
-        self::$registered_actions = new Frm_Form_Action_Factory();
35
-        self::register_actions();
36
-        do_action( 'frm_form_actions_init' );
37
-    }
38
-
39
-    public static function register_actions() {
40
-        $action_classes = apply_filters( 'frm_registered_form_actions', array(
41
-            'email'     => 'FrmEmailAction',
42
-            'wppost'    => 'FrmDefPostAction',
43
-            'register'  => 'FrmDefRegAction',
44
-            'paypal'    => 'FrmDefPayPalAction',
45
-            //'aweber'    => 'FrmDefAweberAction',
46
-            'mailchimp' => 'FrmDefMlcmpAction',
47
-            'twilio'    => 'FrmDefTwilioAction',
48
-            'highrise'  => 'FrmDefHrsAction',
49
-        ) );
50
-
51
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
53
-
54
-        foreach ( $action_classes as $action_class ) {
55
-            self::$registered_actions->register($action_class);
56
-        }
57
-    }
20
+			),
21
+			'has_archive' => false,
22
+		) );
23
+
24
+		/**
25
+		 * post_content: json settings
26
+		 * menu_order: form id
27
+		 * post_excerpt: action type
28
+		 */
29
+
30
+		self::actions_init();
31
+	}
32
+
33
+	public static function actions_init() {
34
+		self::$registered_actions = new Frm_Form_Action_Factory();
35
+		self::register_actions();
36
+		do_action( 'frm_form_actions_init' );
37
+	}
38
+
39
+	public static function register_actions() {
40
+		$action_classes = apply_filters( 'frm_registered_form_actions', array(
41
+			'email'     => 'FrmEmailAction',
42
+			'wppost'    => 'FrmDefPostAction',
43
+			'register'  => 'FrmDefRegAction',
44
+			'paypal'    => 'FrmDefPayPalAction',
45
+			//'aweber'    => 'FrmDefAweberAction',
46
+			'mailchimp' => 'FrmDefMlcmpAction',
47
+			'twilio'    => 'FrmDefTwilioAction',
48
+			'highrise'  => 'FrmDefHrsAction',
49
+		) );
50
+
51
+		include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
+		include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
53
+
54
+		foreach ( $action_classes as $action_class ) {
55
+			self::$registered_actions->register($action_class);
56
+		}
57
+	}
58 58
 
59 59
 	public static function get_form_actions( $action = 'all' ) {
60
-        $temp_actions = self::$registered_actions;
61
-        if ( empty($temp_actions) ) {
62
-            self::actions_init();
63
-            $temp_actions = self::$registered_actions->actions;
64
-        } else {
65
-            $temp_actions = $temp_actions->actions;
66
-        }
60
+		$temp_actions = self::$registered_actions;
61
+		if ( empty($temp_actions) ) {
62
+			self::actions_init();
63
+			$temp_actions = self::$registered_actions->actions;
64
+		} else {
65
+			$temp_actions = $temp_actions->actions;
66
+		}
67 67
 
68
-        $actions = array();
68
+		$actions = array();
69 69
 
70
-        foreach ( $temp_actions as $a ) {
71
-            if ( 'all' != $action && $a->id_base == $action ) {
72
-                return $a;
73
-            }
70
+		foreach ( $temp_actions as $a ) {
71
+			if ( 'all' != $action && $a->id_base == $action ) {
72
+				return $a;
73
+			}
74 74
 
75 75
 			$actions[ $a->id_base ] = $a;
76
-        }
77
-        unset( $temp_actions, $a );
78
-
79
-        $action_limit = 10;
80
-        if ( count( $actions ) <= $action_limit ) {
81
-            return $actions;
82
-        }
83
-
84
-        // remove the last few inactive icons if there are too many
85
-        $temp_actions = $actions;
86
-        arsort( $temp_actions );
87
-        foreach ( $temp_actions as $type => $a ) {
88
-            if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
76
+		}
77
+		unset( $temp_actions, $a );
78
+
79
+		$action_limit = 10;
80
+		if ( count( $actions ) <= $action_limit ) {
81
+			return $actions;
82
+		}
83
+
84
+		// remove the last few inactive icons if there are too many
85
+		$temp_actions = $actions;
86
+		arsort( $temp_actions );
87
+		foreach ( $temp_actions as $type => $a ) {
88
+			if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89 89
 				unset( $actions[ $type ] );
90
-                if ( count( $actions ) <= $action_limit ) {
91
-                    break;
92
-                }
93
-            }
94
-            unset( $type, $a );
95
-        }
90
+				if ( count( $actions ) <= $action_limit ) {
91
+					break;
92
+				}
93
+			}
94
+			unset( $type, $a );
95
+		}
96 96
 
97
-        return $actions;
98
-    }
97
+		return $actions;
98
+	}
99 99
 
100 100
 	/**
101 101
 	 * @since 2.0
102 102
 	 */
103
-    public static function list_actions( $form, $values ) {
104
-        if ( empty( $form ) ) {
105
-            return;
106
-        }
103
+	public static function list_actions( $form, $values ) {
104
+		if ( empty( $form ) ) {
105
+			return;
106
+		}
107 107
 
108 108
 		/**
109 109
 		 * use this hook to migrate old settings into a new action
@@ -113,114 +113,114 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$form_actions = FrmFormAction::get_action_for_form( $form->id );
115 115
 
116
-        $action_controls = self::get_form_actions();
116
+		$action_controls = self::get_form_actions();
117 117
 
118
-        $action_map = array();
118
+		$action_map = array();
119 119
 
120 120
 		foreach ( $action_controls as $key => $control ) {
121
-            $action_map[ $control->id_base ] = $key;
122
-        }
121
+			$action_map[ $control->id_base ] = $key;
122
+		}
123 123
 
124
-    	foreach ( $form_actions as $action ) {
125
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
126
-    	        // don't try and show settings if action no longer exists
127
-    	        continue;
128
-    	    }
124
+		foreach ( $form_actions as $action ) {
125
+			if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
126
+				// don't try and show settings if action no longer exists
127
+				continue;
128
+			}
129 129
 
130
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
131
-    	}
132
-    }
130
+			self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
131
+		}
132
+	}
133 133
 
134 134
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
-        $action_control->_set($action_key);
136
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
-    }
135
+		$action_control->_set($action_key);
136
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
+	}
138 138
 
139
-    public static function add_form_action() {
140
-        check_ajax_referer( 'frm_ajax', 'nonce' );
139
+	public static function add_form_action() {
140
+		check_ajax_referer( 'frm_ajax', 'nonce' );
141 141
 
142
-        global $frm_vars;
142
+		global $frm_vars;
143 143
 
144 144
 		$action_key = absint( $_POST['list_id'] );
145
-        $action_type = sanitize_text_field( $_POST['type'] );
145
+		$action_type = sanitize_text_field( $_POST['type'] );
146 146
 
147
-        $action_control = self::get_form_actions( $action_type );
148
-        $action_control->_set($action_key);
147
+		$action_control = self::get_form_actions( $action_type );
148
+		$action_control->_set($action_key);
149 149
 
150
-        $form_id = absint( $_POST['form_id'] );
150
+		$form_id = absint( $_POST['form_id'] );
151 151
 
152
-        $form_action = $action_control->prepare_new($form_id);
152
+		$form_action = $action_control->prepare_new($form_id);
153 153
 
154
-        $values = array();
155
-        $form = self::fields_to_values($form_id, $values);
154
+		$values = array();
155
+		$form = self::fields_to_values($form_id, $values);
156 156
 
157
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
158
-        wp_die();
159
-    }
157
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
158
+		wp_die();
159
+	}
160 160
 
161
-    public static function fill_action() {
162
-        check_ajax_referer( 'frm_ajax', 'nonce' );
161
+	public static function fill_action() {
162
+		check_ajax_referer( 'frm_ajax', 'nonce' );
163 163
 
164
-        $action_key = absint( $_POST['action_id'] );
165
-        $action_type = sanitize_text_field( $_POST['action_type'] );
164
+		$action_key = absint( $_POST['action_id'] );
165
+		$action_type = sanitize_text_field( $_POST['action_type'] );
166 166
 
167
-        $action_control = self::get_form_actions( $action_type );
168
-        if ( empty($action_control) ) {
169
-            wp_die();
170
-        }
167
+		$action_control = self::get_form_actions( $action_type );
168
+		if ( empty($action_control) ) {
169
+			wp_die();
170
+		}
171 171
 
172
-        $form_action = $action_control->get_single_action( $action_key );
172
+		$form_action = $action_control->get_single_action( $action_key );
173 173
 
174
-        $values = array();
175
-        $form = self::fields_to_values($form_action->menu_order, $values);
174
+		$values = array();
175
+		$form = self::fields_to_values($form_action->menu_order, $values);
176 176
 
177
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
178
-        wp_die();
179
-    }
177
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
178
+		wp_die();
179
+	}
180 180
 
181 181
 	private static function fields_to_values( $form_id, array &$values ) {
182
-        $form = FrmForm::getOne($form_id);
182
+		$form = FrmForm::getOne($form_id);
183 183
 
184 184
 		$values = array( 'fields' => array(), 'id' => $form->id );
185 185
 
186
-        $fields = FrmField::get_all_for_form($form->id);
187
-        foreach ( $fields as $k => $f ) {
188
-            $f = (array) $f;
189
-            $opts = (array) $f['field_options'];
190
-            $f = array_merge($opts, $f);
191
-            if ( ! isset( $f['post_field'] ) ) {
192
-                $f['post_field'] = '';
193
-            }
194
-            $values['fields'][] = $f;
195
-            unset($k, $f);
196
-        }
197
-
198
-        return $form;
199
-    }
186
+		$fields = FrmField::get_all_for_form($form->id);
187
+		foreach ( $fields as $k => $f ) {
188
+			$f = (array) $f;
189
+			$opts = (array) $f['field_options'];
190
+			$f = array_merge($opts, $f);
191
+			if ( ! isset( $f['post_field'] ) ) {
192
+				$f['post_field'] = '';
193
+			}
194
+			$values['fields'][] = $f;
195
+			unset($k, $f);
196
+		}
197
+
198
+		return $form;
199
+	}
200 200
 
201 201
 	public static function update_settings( $form_id ) {
202
-        global $wpdb;
202
+		global $wpdb;
203 203
 
204
-        $registered_actions = self::$registered_actions->actions;
204
+		$registered_actions = self::$registered_actions->actions;
205 205
 
206 206
 		$old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' );
207
-        $new_actions = array();
207
+		$new_actions = array();
208 208
 
209
-        foreach ( $registered_actions as $registered_action ) {
210
-            $action_ids = $registered_action->update_callback($form_id);
211
-            if ( ! empty( $action_ids ) ) {
212
-                $new_actions[] = $action_ids;
213
-            }
214
-        }
209
+		foreach ( $registered_actions as $registered_action ) {
210
+			$action_ids = $registered_action->update_callback($form_id);
211
+			if ( ! empty( $action_ids ) ) {
212
+				$new_actions[] = $action_ids;
213
+			}
214
+		}
215 215
 
216
-        //Only use array_merge if there are new actions
217
-        if ( ! empty( $new_actions ) ) {
218
-            $new_actions = call_user_func_array( 'array_merge', $new_actions );
219
-        }
220
-        $old_actions = array_diff( $old_actions, $new_actions );
216
+		//Only use array_merge if there are new actions
217
+		if ( ! empty( $new_actions ) ) {
218
+			$new_actions = call_user_func_array( 'array_merge', $new_actions );
219
+		}
220
+		$old_actions = array_diff( $old_actions, $new_actions );
221 221
 
222 222
 		self::delete_missing_actions( $old_actions );
223
-    }
223
+	}
224 224
 
225 225
 	public static function delete_missing_actions( $old_actions ) {
226 226
 		if ( ! empty( $old_actions ) ) {
@@ -235,36 +235,36 @@  discard block
 block discarded – undo
235 235
 		self::trigger_actions( 'create', $form_id, $entry_id, 'all', $args );
236 236
 	}
237 237
 
238
-    /**
239
-     * @param string $event
240
-     */
238
+	/**
239
+	 * @param string $event
240
+	 */
241 241
 	public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
242 242
 		$form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type );
243 243
 
244 244
 		if ( empty( $form_actions ) ) {
245
-            return;
246
-        }
245
+			return;
246
+		}
247 247
 
248 248
 		FrmForm::maybe_get_form( $form );
249 249
 
250
-        $link_settings = self::get_form_actions( $type );
251
-        if ( 'all' != $type ) {
252
-            $link_settings = array( $type => $link_settings );
253
-        }
250
+		$link_settings = self::get_form_actions( $type );
251
+		if ( 'all' != $type ) {
252
+			$link_settings = array( $type => $link_settings );
253
+		}
254 254
 
255
-        $stored_actions = $action_priority = array();
255
+		$stored_actions = $action_priority = array();
256 256
 
257 257
 		$importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING;
258 258
 
259
-        foreach ( $form_actions as $action ) {
259
+		foreach ( $form_actions as $action ) {
260 260
 			$trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] );
261 261
 			if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) {
262
-                continue;
263
-            }
262
+				continue;
263
+			}
264 264
 
265
-            if ( ! is_object( $entry ) ) {
266
-                $entry = FrmEntry::getOne( $entry, true );
267
-            }
265
+			if ( ! is_object( $entry ) ) {
266
+				$entry = FrmEntry::getOne( $entry, true );
267
+			}
268 268
 
269 269
 			if ( empty( $entry ) || $entry->is_draft ) {
270 270
 				continue;
@@ -273,66 +273,66 @@  discard block
 block discarded – undo
273 273
 			$child_entry = ( ( $form && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) );
274 274
 
275 275
 			if ( $child_entry ) {
276
-                //don't trigger actions for sub forms
277
-                continue;
278
-            }
276
+				//don't trigger actions for sub forms
277
+				continue;
278
+			}
279 279
 
280
-            // check conditional logic
280
+			// check conditional logic
281 281
 			$stop = FrmFormAction::action_conditions_met( $action, $entry );
282
-            if ( $stop ) {
283
-                continue;
284
-            }
282
+			if ( $stop ) {
283
+				continue;
284
+			}
285 285
 
286
-            // store actions so they can be triggered with the correct priority
287
-            $stored_actions[ $action->ID ] = $action;
288
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
286
+			// store actions so they can be triggered with the correct priority
287
+			$stored_actions[ $action->ID ] = $action;
288
+			$action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
289 289
 
290
-            unset($action);
291
-        }
290
+			unset($action);
291
+		}
292 292
 
293
-        if ( ! empty( $stored_actions ) ) {
294
-            asort($action_priority);
293
+		if ( ! empty( $stored_actions ) ) {
294
+			asort($action_priority);
295 295
 
296
-            // make sure hooks are loaded
297
-            new FrmNotification();
296
+			// make sure hooks are loaded
297
+			new FrmNotification();
298 298
 
299
-            foreach ( $action_priority as $action_id => $priority ) {
300
-                $action = $stored_actions[ $action_id ];
301
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
299
+			foreach ( $action_priority as $action_id => $priority ) {
300
+				$action = $stored_actions[ $action_id ];
301
+				do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
+				do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
303 303
 
304
-                // If post is created, get updated $entry object
305
-                if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
-                    $entry = FrmEntry::getOne($entry->id, true);
307
-                }
308
-            }
309
-        }
310
-    }
304
+				// If post is created, get updated $entry object
305
+				if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
+					$entry = FrmEntry::getOne($entry->id, true);
307
+				}
308
+			}
309
+		}
310
+	}
311 311
 
312 312
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
313
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
314
-            // continue if we know which actions to copy
315
-            return;
316
-        }
313
+		if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
314
+			// continue if we know which actions to copy
315
+			return;
316
+		}
317 317
 
318
-        $action_controls = self::get_form_actions( );
318
+		$action_controls = self::get_form_actions( );
319 319
 
320
-        foreach ( $action_controls as $action_control ) {
321
-            $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
322
-            unset( $action_control );
323
-        }
324
-    }
320
+		foreach ( $action_controls as $action_control ) {
321
+			$action_control->duplicate_form_actions( $form_id, $args['old_id'] );
322
+			unset( $action_control );
323
+		}
324
+	}
325 325
 
326
-    public static function limit_by_type( $where ) {
327
-        global $frm_vars, $wpdb;
326
+	public static function limit_by_type( $where ) {
327
+		global $frm_vars, $wpdb;
328 328
 
329
-        if ( ! isset( $frm_vars['action_type'] ) ) {
330
-            return $where;
331
-        }
329
+		if ( ! isset( $frm_vars['action_type'] ) ) {
330
+			return $where;
331
+		}
332 332
 
333
-        $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
334
-        return $where;
335
-    }
333
+		$where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
334
+		return $where;
335
+	}
336 336
 }
337 337
 
338 338
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		foreach ( $keys as $key ) {
360 360
 			// don't register new action if old action with the same id is already registered
361 361
 			if ( ! isset( $this->actions[ $key ] ) ) {
362
-			    $this->actions[ $key ]->_register();
362
+				$this->actions[ $key ]->_register();
363 363
 			}
364 364
 		}
365 365
 	}
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
             'highrise'  => 'FrmDefHrsAction',
49 49
         ) );
50 50
 
51
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
51
+        include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' );
52
+        include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' );
53 53
 
54 54
         foreach ( $action_classes as $action_class ) {
55
-            self::$registered_actions->register($action_class);
55
+            self::$registered_actions->register( $action_class );
56 56
         }
57 57
     }
58 58
 
59 59
 	public static function get_form_actions( $action = 'all' ) {
60 60
         $temp_actions = self::$registered_actions;
61
-        if ( empty($temp_actions) ) {
61
+        if ( empty( $temp_actions ) ) {
62 62
             self::actions_init();
63 63
             $temp_actions = self::$registered_actions->actions;
64 64
         } else {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 return $a;
73 73
             }
74 74
 
75
-			$actions[ $a->id_base ] = $a;
75
+			$actions[$a->id_base] = $a;
76 76
         }
77 77
         unset( $temp_actions, $a );
78 78
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         arsort( $temp_actions );
87 87
         foreach ( $temp_actions as $type => $a ) {
88 88
             if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89
-				unset( $actions[ $type ] );
89
+				unset( $actions[$type] );
90 90
                 if ( count( $actions ) <= $action_limit ) {
91 91
                     break;
92 92
                 }
@@ -118,22 +118,22 @@  discard block
 block discarded – undo
118 118
         $action_map = array();
119 119
 
120 120
 		foreach ( $action_controls as $key => $control ) {
121
-            $action_map[ $control->id_base ] = $key;
121
+            $action_map[$control->id_base] = $key;
122 122
         }
123 123
 
124 124
     	foreach ( $form_actions as $action ) {
125
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
125
+    	    if ( ! isset( $action_map[$action->post_excerpt] ) ) {
126 126
     	        // don't try and show settings if action no longer exists
127 127
     	        continue;
128 128
     	    }
129 129
 
130
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
130
+    		self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values );
131 131
     	}
132 132
     }
133 133
 
134 134
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
-        $action_control->_set($action_key);
136
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
135
+        $action_control->_set( $action_key );
136
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
137 137
     }
138 138
 
139 139
     public static function add_form_action() {
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
         $action_type = sanitize_text_field( $_POST['type'] );
146 146
 
147 147
         $action_control = self::get_form_actions( $action_type );
148
-        $action_control->_set($action_key);
148
+        $action_control->_set( $action_key );
149 149
 
150 150
         $form_id = absint( $_POST['form_id'] );
151 151
 
152
-        $form_action = $action_control->prepare_new($form_id);
152
+        $form_action = $action_control->prepare_new( $form_id );
153 153
 
154 154
         $values = array();
155
-        $form = self::fields_to_values($form_id, $values);
155
+        $form = self::fields_to_values( $form_id, $values );
156 156
 
157
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
157
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
158 158
         wp_die();
159 159
     }
160 160
 
@@ -165,34 +165,34 @@  discard block
 block discarded – undo
165 165
         $action_type = sanitize_text_field( $_POST['action_type'] );
166 166
 
167 167
         $action_control = self::get_form_actions( $action_type );
168
-        if ( empty($action_control) ) {
168
+        if ( empty( $action_control ) ) {
169 169
             wp_die();
170 170
         }
171 171
 
172 172
         $form_action = $action_control->get_single_action( $action_key );
173 173
 
174 174
         $values = array();
175
-        $form = self::fields_to_values($form_action->menu_order, $values);
175
+        $form = self::fields_to_values( $form_action->menu_order, $values );
176 176
 
177
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
177
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
178 178
         wp_die();
179 179
     }
180 180
 
181 181
 	private static function fields_to_values( $form_id, array &$values ) {
182
-        $form = FrmForm::getOne($form_id);
182
+        $form = FrmForm::getOne( $form_id );
183 183
 
184 184
 		$values = array( 'fields' => array(), 'id' => $form->id );
185 185
 
186
-        $fields = FrmField::get_all_for_form($form->id);
186
+        $fields = FrmField::get_all_for_form( $form->id );
187 187
         foreach ( $fields as $k => $f ) {
188 188
             $f = (array) $f;
189 189
             $opts = (array) $f['field_options'];
190
-            $f = array_merge($opts, $f);
190
+            $f = array_merge( $opts, $f );
191 191
             if ( ! isset( $f['post_field'] ) ) {
192 192
                 $f['post_field'] = '';
193 193
             }
194 194
             $values['fields'][] = $f;
195
-            unset($k, $f);
195
+            unset( $k, $f );
196 196
         }
197 197
 
198 198
         return $form;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $new_actions = array();
208 208
 
209 209
         foreach ( $registered_actions as $registered_action ) {
210
-            $action_ids = $registered_action->update_callback($form_id);
210
+            $action_ids = $registered_action->update_callback( $form_id );
211 211
             if ( ! empty( $action_ids ) ) {
212 212
                 $new_actions[] = $action_ids;
213 213
             }
@@ -284,33 +284,33 @@  discard block
 block discarded – undo
284 284
             }
285 285
 
286 286
             // store actions so they can be triggered with the correct priority
287
-            $stored_actions[ $action->ID ] = $action;
288
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
287
+            $stored_actions[$action->ID] = $action;
288
+            $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority'];
289 289
 
290
-            unset($action);
290
+            unset( $action );
291 291
         }
292 292
 
293 293
         if ( ! empty( $stored_actions ) ) {
294
-            asort($action_priority);
294
+            asort( $action_priority );
295 295
 
296 296
             // make sure hooks are loaded
297 297
             new FrmNotification();
298 298
 
299 299
             foreach ( $action_priority as $action_id => $priority ) {
300
-                $action = $stored_actions[ $action_id ];
301
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
300
+                $action = $stored_actions[$action_id];
301
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
302
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
303 303
 
304 304
                 // If post is created, get updated $entry object
305 305
                 if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
-                    $entry = FrmEntry::getOne($entry->id, true);
306
+                    $entry = FrmEntry::getOne( $entry->id, true );
307 307
                 }
308 308
             }
309 309
         }
310 310
     }
311 311
 
312 312
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
313
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
313
+        if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
314 314
             // continue if we know which actions to copy
315 315
             return;
316 316
         }
@@ -344,22 +344,22 @@  discard block
 block discarded – undo
344 344
 	}
345 345
 
346 346
 	public function register( $action_class ) {
347
-		$this->actions[ $action_class ] = new $action_class();
347
+		$this->actions[$action_class] = new $action_class();
348 348
 	}
349 349
 
350 350
 	public function unregister( $action_class ) {
351
-		if ( isset( $this->actions[ $action_class ] ) ) {
352
-			unset($this->actions[ $action_class ]);
351
+		if ( isset( $this->actions[$action_class] ) ) {
352
+			unset( $this->actions[$action_class] );
353 353
 		}
354 354
 	}
355 355
 
356 356
 	public function _register_actions() {
357
-		$keys = array_keys($this->actions);
357
+		$keys = array_keys( $this->actions );
358 358
 
359 359
 		foreach ( $keys as $key ) {
360 360
 			// don't register new action if old action with the same id is already registered
361
-			if ( ! isset( $this->actions[ $key ] ) ) {
362
-			    $this->actions[ $key ]->_register();
361
+			if ( ! isset( $this->actions[$key] ) ) {
362
+			    $this->actions[$key]->_register();
363 363
 			}
364 364
 		}
365 365
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmHooksController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,8 +143,8 @@
 block discarded – undo
143 143
         add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
144 144
 
145 145
 		// Addons Controller
146
-		add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
147
-		add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
146
+		add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
147
+		add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
148 148
 
149 149
         // Fields Controller
150 150
         add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
Please login to merge, or discard this patch.
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,91 +1,91 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmHooksController {
4
-    /**
5
-     * Trigger plugin-wide hook loading
6
-     */
7
-    public static function trigger_load_hook( $hooks = 'load_hooks' ) {
8
-        $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) );
9
-
10
-        $trigger_hooks = $hooks;
11
-        $hooks = (array) $hooks;
12
-
13
-        if ( 'load_hooks' == $trigger_hooks ) {
14
-            if ( is_admin() ) {
15
-                $hooks[] = 'load_admin_hooks';
16
-                if ( defined( 'DOING_AJAX' ) ) {
17
-                    $hooks[] = 'load_ajax_hooks';
18
-                    $hooks[] = 'load_form_hooks';
19
-                }
20
-            }
21
-
22
-            if ( is_multisite() ) {
23
-                $hooks[] = 'load_multisite_hooks';
24
-            }
25
-        } else {
26
-            // Make sure the hooks are only triggered once
27
-            add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' );
28
-        }
29
-        unset( $trigger_hooks );
30
-
31
-        // Instansiate Controllers
32
-        foreach ( $controllers as $c ) {
33
-            foreach ( $hooks as $hook ) {
4
+	/**
5
+	 * Trigger plugin-wide hook loading
6
+	 */
7
+	public static function trigger_load_hook( $hooks = 'load_hooks' ) {
8
+		$controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) );
9
+
10
+		$trigger_hooks = $hooks;
11
+		$hooks = (array) $hooks;
12
+
13
+		if ( 'load_hooks' == $trigger_hooks ) {
14
+			if ( is_admin() ) {
15
+				$hooks[] = 'load_admin_hooks';
16
+				if ( defined( 'DOING_AJAX' ) ) {
17
+					$hooks[] = 'load_ajax_hooks';
18
+					$hooks[] = 'load_form_hooks';
19
+				}
20
+			}
21
+
22
+			if ( is_multisite() ) {
23
+				$hooks[] = 'load_multisite_hooks';
24
+			}
25
+		} else {
26
+			// Make sure the hooks are only triggered once
27
+			add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' );
28
+		}
29
+		unset( $trigger_hooks );
30
+
31
+		// Instansiate Controllers
32
+		foreach ( $controllers as $c ) {
33
+			foreach ( $hooks as $hook ) {
34 34
 				call_user_func( array( $c, $hook ) );
35 35
 				unset( $hook );
36
-            }
36
+			}
37 37
 			unset( $c );
38
-        }
38
+		}
39 39
 
40
-    }
40
+	}
41 41
 
42
-    public static function trigger_load_form_hooks() {
43
-        self::trigger_load_hook( 'load_form_hooks' );
44
-    }
42
+	public static function trigger_load_form_hooks() {
43
+		self::trigger_load_hook( 'load_form_hooks' );
44
+	}
45 45
 
46 46
 	public static function load_hooks() {
47
-        if ( ! is_admin() ) {
48
-            add_filter( 'the_content', 'FrmAppController::page_route', 10 );
49
-        }
50
-
51
-        add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
52
-        add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 );
53
-
54
-        // Entries controller
55
-        add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
56
-        add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 );
57
-        add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
58
-        add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 );
59
-        add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 );
60
-
61
-        // Form Actions Controller
62
-        add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
47
+		if ( ! is_admin() ) {
48
+			add_filter( 'the_content', 'FrmAppController::page_route', 10 );
49
+		}
50
+
51
+		add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
52
+		add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 );
53
+
54
+		// Entries controller
55
+		add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
56
+		add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 );
57
+		add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
58
+		add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 );
59
+		add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 );
60
+
61
+		// Form Actions Controller
62
+		add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
63 63
 		add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 );
64 64
 
65
-        // Forms Controller
66
-        add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
65
+		// Forms Controller
66
+		add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
67 67
 		add_action( 'init', 'FrmFormsController::front_head' );
68
-        add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
69
-        add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
70
-        add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
68
+		add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
69
+		add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
70
+		add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
71 71
 		add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 );
72 72
 
73 73
 		add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' );
74 74
 
75
-        // Form Shortcodes
76
-        add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
75
+		// Form Shortcodes
76
+		add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
77 77
 
78
-        // Styles Controller
79
-        add_action( 'init', 'FrmStylesController::register_post_types', 0 );
80
-        add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
81
-        add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
82
-        add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
83
-    }
78
+		// Styles Controller
79
+		add_action( 'init', 'FrmStylesController::register_post_types', 0 );
80
+		add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
81
+		add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
82
+		add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
83
+	}
84 84
 
85 85
 	public static function load_admin_hooks() {
86
-        add_action( 'admin_menu', 'FrmAppController::menu', 1 );
87
-        add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
88
-        add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
86
+		add_action( 'admin_menu', 'FrmAppController::menu', 1 );
87
+		add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
88
+		add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
89 89
 		add_action( 'admin_init', 'FrmAppController::admin_init', 11 );
90 90
 		add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' );
91 91
 		add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
@@ -94,122 +94,122 @@  discard block
 block discarded – undo
94 94
 		// Addons Controller
95 95
 		add_action( 'admin_menu', 'FrmAddonsController::menu', 100 );
96 96
 
97
-        // Entries Controller
98
-        add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
99
-        add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 );
100
-        add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
101
-        add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
102
-        add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
97
+		// Entries Controller
98
+		add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
99
+		add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 );
100
+		add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
101
+		add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
102
+		add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
103 103
 
104
-        // Fields Controller
105
-        add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' );
104
+		// Fields Controller
105
+		add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' );
106 106
 
107
-        // Form Actions Controller
108
-        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
109
-            add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
110
-        }
111
-        add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
107
+		// Form Actions Controller
108
+		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
109
+			add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
110
+		}
111
+		add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
112 112
 
113
-        // Forms Controller
114
-        add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
115
-        add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
113
+		// Forms Controller
114
+		add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
115
+		add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
116 116
 
117
-        add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
118
-        add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
117
+		add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
118
+		add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
119 119
 		add_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
120 120
 
121
-        // Forms Model
122
-        add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
121
+		// Forms Model
122
+		add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
123 123
 
124
-        // Settings Controller
125
-        add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
126
-        add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
124
+		// Settings Controller
125
+		add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
126
+		add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
127 127
 
128
-        // Styles Controller
129
-        add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
130
-        add_action( 'admin_init', 'FrmStylesController::admin_init' );
128
+		// Styles Controller
129
+		add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
130
+		add_action( 'admin_init', 'FrmStylesController::admin_init' );
131 131
 
132
-        // XML Controller
133
-        add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
134
-    }
132
+		// XML Controller
133
+		add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
134
+	}
135 135
 
136 136
 	public static function load_ajax_hooks() {
137 137
 		add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' );
138 138
 		add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' );
139 139
 		add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' );
140
-        add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
141
-        add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
140
+		add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
141
+		add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
142 142
 
143 143
 		// Addons Controller
144 144
 		add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
145 145
 		add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
146 146
 
147
-        // Fields Controller
148
-        add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
149
-        add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
150
-        add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' );
151
-        add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' );
152
-        add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' );
153
-        add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
154
-        add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
155
-        add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' );
156
-        add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' );
157
-        add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' );
158
-        add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' );
159
-        add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
160
-        add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' );
161
-
162
-        // Form Actions Controller
163
-        add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
164
-        add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
165
-
166
-        // Forms Controller
147
+		// Fields Controller
148
+		add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
149
+		add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
150
+		add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' );
151
+		add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' );
152
+		add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' );
153
+		add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
154
+		add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
155
+		add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' );
156
+		add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' );
157
+		add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' );
158
+		add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' );
159
+		add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
160
+		add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' );
161
+
162
+		// Form Actions Controller
163
+		add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
164
+		add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
165
+
166
+		// Forms Controller
167 167
 		add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' );
168 168
 		add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' );
169 169
 		add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' );
170 170
 		add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' );
171
-        add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
172
-        add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
173
-        add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
174
-        add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
175
-
176
-        // Styles Controller
177
-        add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
178
-        add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
179
-        add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
180
-        add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
171
+		add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
172
+		add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
173
+		add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
174
+		add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
175
+
176
+		// Styles Controller
177
+		add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
178
+		add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
179
+		add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
180
+		add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
181 181
 		add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' );
182 182
 		add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
183 183
 
184
-        // XML Controller
184
+		// XML Controller
185 185
 		add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' );
186 186
 		add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' );
187
-        add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
188
-    }
187
+		add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
188
+	}
189 189
 
190 190
 	public static function load_form_hooks() {
191
-        // Fields Controller
192
-        add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
193
-        add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
194
-        add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
195
-        add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
191
+		// Fields Controller
192
+		add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
193
+		add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
194
+		add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
195
+		add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
196 196
 
197 197
 		// Forms Controller
198 198
 		add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' );
199 199
 
200
-        // Styles Controller
201
-        add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
202
-    }
200
+		// Styles Controller
201
+		add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
202
+	}
203 203
 
204 204
 	public static function load_view_hooks() {
205
-        // Hooks go here when a view is loaded
206
-    }
205
+		// Hooks go here when a view is loaded
206
+	}
207 207
 
208 208
 	public static function load_multisite_hooks() {
209 209
 		add_action( 'init', 'FrmAppController::front_head' );
210 210
 		add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
211 211
 
212
-        // drop tables when mu site is deleted
213
-        add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
214
-    }
212
+		// drop tables when mu site is deleted
213
+		add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
214
+	}
215 215
 }
Please login to merge, or discard this patch.
classes/controllers/FrmSettingsController.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -2,78 +2,78 @@
 block discarded – undo
2 2
 
3 3
 class FrmSettingsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		// Make sure admins can see the menu items
7 7
 		FrmAppHelper::force_capability( 'frm_change_settings' );
8 8
 
9
-        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
-    }
9
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
+	}
11 11
 
12
-    public static function license_box() {
12
+	public static function license_box() {
13 13
 		$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14
-        include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
-    }
14
+		include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
+	}
16 16
 
17
-    public static function display_form( $errors = array(), $message = '' ) {
18
-        global $frm_vars;
17
+	public static function display_form( $errors = array(), $message = '' ) {
18
+		global $frm_vars;
19 19
 
20
-        $frm_settings = FrmAppHelper::get_settings();
21
-        $frm_roles = FrmAppHelper::frm_capabilities();
20
+		$frm_settings = FrmAppHelper::get_settings();
21
+		$frm_roles = FrmAppHelper::frm_capabilities();
22 22
 
23
-        $uploads = wp_upload_dir();
24
-        $target_path = $uploads['basedir'] . '/formidable/css';
23
+		$uploads = wp_upload_dir();
24
+		$target_path = $uploads['basedir'] . '/formidable/css';
25 25
 
26 26
 		$sections = array();
27 27
 		if ( apply_filters( 'frm_include_addon_page', false ) ) {
28 28
 			$sections['licenses'] = array( 'class' => 'FrmAddonsController', 'function' => 'show_addons' );
29 29
 		}
30
-        $sections = apply_filters( 'frm_add_settings_section', $sections );
30
+		$sections = apply_filters( 'frm_add_settings_section', $sections );
31 31
 
32
-        $captcha_lang = FrmAppHelper::locales( 'captcha' );
32
+		$captcha_lang = FrmAppHelper::locales( 'captcha' );
33 33
 
34
-        require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
35
-    }
34
+		require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
35
+	}
36 36
 
37
-    public static function process_form( $stop_load = false ) {
38
-        global $frm_vars;
37
+	public static function process_form( $stop_load = false ) {
38
+		global $frm_vars;
39 39
 
40
-        $frm_settings = FrmAppHelper::get_settings();
40
+		$frm_settings = FrmAppHelper::get_settings();
41 41
 
42 42
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
43 43
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
44
-            wp_die( $frm_settings->admin_permission );
45
-        }
44
+			wp_die( $frm_settings->admin_permission );
45
+		}
46 46
 
47
-        $errors = array();
48
-        $message = '';
47
+		$errors = array();
48
+		$message = '';
49 49
 
50
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
51
-            //$errors = $frm_settings->validate($_POST,array());
52
-            $frm_settings->update( stripslashes_deep( $_POST ) );
50
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
51
+			//$errors = $frm_settings->validate($_POST,array());
52
+			$frm_settings->update( stripslashes_deep( $_POST ) );
53 53
 
54
-            if ( empty( $errors ) ) {
55
-                $frm_settings->store();
56
-                $message = __( 'Settings Saved', 'formidable' );
57
-            }
58
-        } else {
59
-            $message = __( 'Settings Saved', 'formidable' );
60
-        }
54
+			if ( empty( $errors ) ) {
55
+				$frm_settings->store();
56
+				$message = __( 'Settings Saved', 'formidable' );
57
+			}
58
+		} else {
59
+			$message = __( 'Settings Saved', 'formidable' );
60
+		}
61 61
 
62 62
 		if ( $stop_load == 'stop_load' ) {
63
-            $frm_vars['settings_routed'] = true;
64
-            return;
65
-        }
63
+			$frm_vars['settings_routed'] = true;
64
+			return;
65
+		}
66 66
 
67
-        self::display_form( $errors, $message );
68
-    }
67
+		self::display_form( $errors, $message );
68
+	}
69 69
 
70
-    public static function route( $stop_load = false ) {
71
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
70
+	public static function route( $stop_load = false ) {
71
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
72 72
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
73
-        if ( $action == 'process-form' ) {
74
-            return self::process_form( $stop_load );
75
-        } else if ( $stop_load != 'stop_load' ) {
76
-            return self::display_form();
77
-        }
78
-    }
73
+		if ( $action == 'process-form' ) {
74
+			return self::process_form( $stop_load );
75
+		} else if ( $stop_load != 'stop_load' ) {
76
+			return self::display_form();
77
+		}
78
+	}
79 79
 }
Please login to merge, or discard this patch.
classes/controllers/FrmStylesController.php 2 patches
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -41,25 +41,25 @@  discard block
 block discarded – undo
41 41
     }
42 42
 
43 43
     public static function menu() {
44
-        add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
44
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' );
45 45
     }
46 46
 
47 47
     public static function admin_init() {
48
-        if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
48
+        if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) {
49 49
             return;
50 50
         }
51 51
 
52 52
         self::load_pro_hooks();
53
-        wp_enqueue_script('jquery-ui-datepicker');
53
+        wp_enqueue_script( 'jquery-ui-datepicker' );
54 54
 
55 55
         $version = FrmAppHelper::plugin_version();
56 56
 		wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version );
57 57
 
58
-        wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
58
+        wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' );
59 59
 
60
-        $style = apply_filters('frm_style_head', false);
60
+        $style = apply_filters( 'frm_style_head', false );
61 61
         if ( $style ) {
62
-            wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
62
+            wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php' ) . '?action=frmpro_load_css&flat=1&' . http_build_query( $style->post_content ) );
63 63
         }
64 64
     }
65 65
 
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 
130 130
 	public static function new_style( $return = '' ) {
131 131
         FrmAppHelper::update_message( __( 'create multiple styling templates', 'formidable' ), 'wrap' );
132
-        self::load_styler('default');
132
+        self::load_styler( 'default' );
133 133
     }
134 134
 
135 135
 	public static function duplicate() {
136 136
 		FrmAppHelper::update_message( __( 'duplicate styling templates', 'formidable' ), 'wrap' );
137
-		self::load_styler('default');
137
+		self::load_styler( 'default' );
138 138
 	}
139 139
 
140 140
 	public static function edit( $style_id = false, $message = '' ) {
141 141
         if ( ! $style_id ) {
142 142
 			$style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
143
-            if ( empty($style_id) ) {
143
+            if ( empty( $style_id ) ) {
144 144
                 $style_id = 'default';
145 145
             }
146 146
         }
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
         if ( 'default' == $style_id ) {
149 149
             $style = 'default';
150 150
         } else {
151
-            $frm_style = new FrmStyle($style_id);
151
+            $frm_style = new FrmStyle( $style_id );
152 152
             $style = $frm_style->get_one();
153 153
             $style = $style->ID;
154 154
         }
155 155
 
156
-        self::load_styler($style, $message);
156
+        self::load_styler( $style, $message );
157 157
     }
158 158
 
159 159
     public static function save() {
@@ -163,17 +163,17 @@  discard block
 block discarded – undo
163 163
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' );
164 164
 
165 165
 		if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) {
166
-            $id = $frm_style->update($post_id);
167
-            if ( empty($post_id) && ! empty($id) ) {
166
+            $id = $frm_style->update( $post_id );
167
+            if ( empty( $post_id ) && ! empty( $id ) ) {
168 168
                 // set the post id to the new style so it will be loaded for editing
169
-                $post_id = reset($id);
169
+                $post_id = reset( $id );
170 170
             }
171 171
             // include the CSS that includes this style
172 172
 			echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />';
173 173
             $message = __( 'Your styling settings have been saved.', 'formidable' );
174 174
         }
175 175
 
176
-        return self::edit($post_id, $message);
176
+        return self::edit( $post_id, $message );
177 177
     }
178 178
 
179 179
 	public static function load_styler( $style, $message = '' ) {
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
         $frm_style = new FrmStyle();
183 183
         $styles = $frm_style->get_all();
184 184
 
185
-        if ( is_numeric($style) ) {
186
-            $style = $styles[ $style ];
185
+        if ( is_numeric( $style ) ) {
186
+            $style = $styles[$style];
187 187
         } else if ( 'default' == $style ) {
188
-            $style = $frm_style->get_default_style($styles);
188
+            $style = $frm_style->get_default_style( $styles );
189 189
         }
190 190
 
191 191
         self::add_meta_boxes();
192 192
 
193
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
193
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' );
194 194
     }
195 195
 
196 196
 	/**
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 	private static function manage( $message = '', $forms = array() ) {
201 201
         $frm_style = new FrmStyle();
202 202
         $styles = $frm_style->get_all();
203
-        $default_style = $frm_style->get_default_style($styles);
203
+        $default_style = $frm_style->get_default_style( $styles );
204 204
 
205
-        if ( empty($forms) ) {
205
+        if ( empty( $forms ) ) {
206 206
             $forms = FrmForm::get_published_forms();
207 207
         }
208 208
 
209
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
209
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' );
210 210
     }
211 211
 
212 212
     private static function manage_styles() {
@@ -219,31 +219,31 @@  discard block
 block discarded – undo
219 219
 
220 220
 		$forms = FrmForm::get_published_forms();
221 221
         foreach ( $forms as $form ) {
222
-            if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
222
+            if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) {
223 223
                 continue;
224 224
             }
225 225
 
226
-            $form->options['custom_style'] = $_POST['style'][ $form->id ];
226
+            $form->options['custom_style'] = $_POST['style'][$form->id];
227 227
 
228 228
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
229
-            unset($form);
229
+            unset( $form );
230 230
         }
231 231
 
232 232
         $message = __( 'Your form styles have been saved.', 'formidable' );
233
-        return self::manage($message, $forms);
233
+        return self::manage( $message, $forms );
234 234
     }
235 235
 
236 236
     public static function custom_css( $message = '', $style = null ) {
237
-        wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
238
-        wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
+        wp_enqueue_style( 'codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css' );
238
+        wp_enqueue_script( 'codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7' );
239 239
         wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
240 240
 
241
-        if ( ! isset($style) ) {
241
+        if ( ! isset( $style ) ) {
242 242
             $frm_style = new FrmStyle();
243 243
             $style = $frm_style->get_default_style();
244 244
         }
245 245
 
246
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
246
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' );
247 247
     }
248 248
 
249 249
     public static function save_css() {
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' );
254 254
 		$nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' );
255 255
 		if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) {
256
-            $frm_style->update($post_id);
256
+            $frm_style->update( $post_id );
257 257
             $message = __( 'Your styling settings have been saved.', 'formidable' );
258 258
         }
259 259
 
260
-        return self::custom_css($message);
260
+        return self::custom_css( $message );
261 261
     }
262 262
 
263 263
     public static function route() {
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 
304 304
         // remove the # from the colors
305 305
         foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
306
-            if ( ! is_array($v) && strpos($v, '#') === 0 ) {
307
-                $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
+            if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) {
307
+                $_GET['frm_style_setting']['post_content'][$k] = str_replace( '#', '', $v );
308 308
             }
309 309
         }
310 310
 
311 311
         echo '<style type="text/css">';
312
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
312
+        include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
313 313
         echo '</style>';
314 314
         wp_die();
315 315
     }
@@ -331,24 +331,24 @@  discard block
 block discarded – undo
331 331
         );
332 332
 
333 333
         foreach ( $meta_boxes as $nicename => $name ) {
334
-            add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
335
-            unset($nicename, $name);
334
+            add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
335
+            unset( $nicename, $name );
336 336
         }
337 337
     }
338 338
 
339 339
 	public static function include_style_section( $atts, $sec ) {
340
-        extract($atts);
340
+        extract( $atts );
341 341
 		$current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
342
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
342
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' );
343 343
     }
344 344
 
345 345
     public static function load_css() {
346
-        header('Content-type: text/css');
346
+        header( 'Content-type: text/css' );
347 347
 
348 348
         $frm_style = new FrmStyle();
349 349
         $defaults = $frm_style->get_defaults();
350 350
 
351
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
351
+        include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
352 352
         wp_die();
353 353
     }
354 354
 
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
             $style = 'default';
408 408
         }
409 409
 
410
-        $frm_style = new FrmStyle($style);
410
+        $frm_style = new FrmStyle( $style );
411 411
         $style = $frm_style->get_one();
412 412
 
413 413
         if ( $style ) {
414
-            $class .= ' frm_style_'. $style->post_name;
414
+            $class .= ' frm_style_' . $style->post_name;
415 415
         }
416 416
 
417 417
         return $class;
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
      * @param string $val
422 422
      */
423 423
 	public static function get_style_val( $val, $form = 'default' ) {
424
-        $style = self::get_form_style($form);
425
-        if ( $style && isset( $style->post_content[ $val ] ) ) {
426
-            return $style->post_content[ $val ];
424
+        $style = self::get_form_style( $form );
425
+        if ( $style && isset( $style->post_content[$val] ) ) {
426
+            return $style->post_content[$val];
427 427
         }
428 428
     }
429 429
 
430 430
 	public static function show_entry_styles( $default_styles ) {
431
-        $frm_style = new FrmStyle('default');
431
+        $frm_style = new FrmStyle( 'default' );
432 432
         $style = $frm_style->get_one();
433 433
 
434 434
         if ( ! $style ) {
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
             } else if ( 'alt_bg_color' == $name ) {
443 443
                 $setting = 'bg_color_active';
444 444
             }
445
-            $default_styles[ $name ] = $style->post_content[ $setting ];
446
-            unset($name, $val);
445
+            $default_styles[$name] = $style->post_content[$setting];
446
+            unset( $name, $val );
447 447
         }
448 448
 
449 449
         return $default_styles;
450 450
     }
451 451
 
452 452
 	public static function &important_style( $important, $field ) {
453
-        $important = self::get_style_val('important_style', $field['form_id']);
453
+        $important = self::get_style_val( 'important_style', $field['form_id'] );
454 454
         return $important;
455 455
     }
456 456
 
@@ -476,18 +476,18 @@  discard block
 block discarded – undo
476 476
     	$i = 0;
477 477
     	$first_open = false;
478 478
     	do {
479
-			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
479
+			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) {
480 480
 				break;
481 481
 			}
482 482
 
483 483
     		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
484
-    			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
485
-    				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
+    			if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) {
485
+    				foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
486 486
     					if ( false == $box || ! $box['title'] ) {
487 487
     						continue;
488 488
 						}
489 489
 
490
-    					$i++;
490
+    					$i ++;
491 491
     					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
492 492
 
493 493
     					if ( ! $first_open && empty( $hidden_class ) ) {
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmStylesController {
4
-    public static $post_type = 'frm_styles';
5
-    public static $screen = 'formidable_page_formidable-styles';
6
-
7
-    public static function load_pro_hooks() {
8
-        if ( FrmAppHelper::pro_is_installed() ) {
9
-            FrmProStylesController::load_pro_hooks();
10
-        }
11
-    }
12
-
13
-    public static function register_post_types() {
14
-        register_post_type( self::$post_type, array(
15
-            'label' => __( 'Styles', 'formidable' ),
16
-            'public' => false,
17
-            'show_ui' => false,
18
-            'capability_type' => 'page',
4
+	public static $post_type = 'frm_styles';
5
+	public static $screen = 'formidable_page_formidable-styles';
6
+
7
+	public static function load_pro_hooks() {
8
+		if ( FrmAppHelper::pro_is_installed() ) {
9
+			FrmProStylesController::load_pro_hooks();
10
+		}
11
+	}
12
+
13
+	public static function register_post_types() {
14
+		register_post_type( self::$post_type, array(
15
+			'label' => __( 'Styles', 'formidable' ),
16
+			'public' => false,
17
+			'show_ui' => false,
18
+			'capability_type' => 'page',
19 19
 			'capabilities' => array(
20 20
 				'edit_post'		=> 'frm_change_settings',
21 21
 				'edit_posts'	=> 'frm_change_settings',
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 				'delete_posts'	=> 'frm_change_settings',
26 26
 				'read_private_posts' => 'read_private_posts',
27 27
 			),
28
-            'supports' => array(
28
+			'supports' => array(
29 29
 				'title',
30
-            ),
31
-            'has_archive' => false,
32
-            'labels' => array(
30
+			),
31
+			'has_archive' => false,
32
+			'labels' => array(
33 33
 				'name' => __( 'Styles', 'formidable' ),
34 34
 				'singular_name' => __( 'Style', 'formidable' ),
35 35
 				'menu_name' => __( 'Style', 'formidable' ),
@@ -37,31 +37,31 @@  discard block
 block discarded – undo
37 37
 				'add_new_item' => __( 'Create a New Style', 'formidable' ),
38 38
 				'edit_item'    => __( 'Edit Style', 'formidable' ),
39 39
 			),
40
-        ) );
41
-    }
40
+		) );
41
+	}
42 42
 
43
-    public static function menu() {
44
-        add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
45
-    }
43
+	public static function menu() {
44
+		add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
45
+	}
46 46
 
47
-    public static function admin_init() {
48
-        if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
49
-            return;
50
-        }
47
+	public static function admin_init() {
48
+		if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
49
+			return;
50
+		}
51 51
 
52
-        self::load_pro_hooks();
53
-        wp_enqueue_script('jquery-ui-datepicker');
52
+		self::load_pro_hooks();
53
+		wp_enqueue_script('jquery-ui-datepicker');
54 54
 
55
-        $version = FrmAppHelper::plugin_version();
55
+		$version = FrmAppHelper::plugin_version();
56 56
 		wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version );
57 57
 
58
-        wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
58
+		wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
59 59
 
60
-        $style = apply_filters('frm_style_head', false);
61
-        if ( $style ) {
62
-            wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
63
-        }
64
-    }
60
+		$style = apply_filters('frm_style_head', false);
61
+		if ( $style ) {
62
+			wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
63
+		}
64
+	}
65 65
 
66 66
 	public static function enqueue_css( $register = 'enqueue' ) {
67 67
 		global $frm_vars;
@@ -128,227 +128,227 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	public static function new_style( $return = '' ) {
131
-        self::load_styler('default');
132
-    }
131
+		self::load_styler('default');
132
+	}
133 133
 
134 134
 	public static function duplicate() {
135 135
 		self::load_styler('default');
136 136
 	}
137 137
 
138 138
 	public static function edit( $style_id = false, $message = '' ) {
139
-        if ( ! $style_id ) {
139
+		if ( ! $style_id ) {
140 140
 			$style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
141
-            if ( empty($style_id) ) {
142
-                $style_id = 'default';
143
-            }
144
-        }
145
-
146
-        if ( 'default' == $style_id ) {
147
-            $style = 'default';
148
-        } else {
149
-            $frm_style = new FrmStyle($style_id);
150
-            $style = $frm_style->get_one();
151
-            $style = $style->ID;
152
-        }
153
-
154
-        self::load_styler($style, $message);
155
-    }
156
-
157
-    public static function save() {
158
-        $frm_style = new FrmStyle();
159
-        $message = '';
141
+			if ( empty($style_id) ) {
142
+				$style_id = 'default';
143
+			}
144
+		}
145
+
146
+		if ( 'default' == $style_id ) {
147
+			$style = 'default';
148
+		} else {
149
+			$frm_style = new FrmStyle($style_id);
150
+			$style = $frm_style->get_one();
151
+			$style = $style->ID;
152
+		}
153
+
154
+		self::load_styler($style, $message);
155
+	}
156
+
157
+	public static function save() {
158
+		$frm_style = new FrmStyle();
159
+		$message = '';
160 160
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' );
161 161
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' );
162 162
 
163 163
 		if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) {
164
-            $id = $frm_style->update($post_id);
165
-            if ( empty($post_id) && ! empty($id) ) {
166
-                // set the post id to the new style so it will be loaded for editing
167
-                $post_id = reset($id);
168
-            }
169
-            // include the CSS that includes this style
164
+			$id = $frm_style->update($post_id);
165
+			if ( empty($post_id) && ! empty($id) ) {
166
+				// set the post id to the new style so it will be loaded for editing
167
+				$post_id = reset($id);
168
+			}
169
+			// include the CSS that includes this style
170 170
 			echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />';
171
-            $message = __( 'Your styling settings have been saved.', 'formidable' );
172
-        }
171
+			$message = __( 'Your styling settings have been saved.', 'formidable' );
172
+		}
173 173
 
174
-        return self::edit($post_id, $message);
175
-    }
174
+		return self::edit($post_id, $message);
175
+	}
176 176
 
177 177
 	public static function load_styler( $style, $message = '' ) {
178
-        global $frm_settings;
178
+		global $frm_settings;
179 179
 
180
-        $frm_style = new FrmStyle();
181
-        $styles = $frm_style->get_all();
180
+		$frm_style = new FrmStyle();
181
+		$styles = $frm_style->get_all();
182 182
 
183
-        if ( is_numeric($style) ) {
184
-            $style = $styles[ $style ];
185
-        } else if ( 'default' == $style ) {
186
-            $style = $frm_style->get_default_style($styles);
187
-        }
183
+		if ( is_numeric($style) ) {
184
+			$style = $styles[ $style ];
185
+		} else if ( 'default' == $style ) {
186
+			$style = $frm_style->get_default_style($styles);
187
+		}
188 188
 
189
-        self::add_meta_boxes();
189
+		self::add_meta_boxes();
190 190
 
191
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
192
-    }
191
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
192
+	}
193 193
 
194 194
 	/**
195 195
 	 * @param string $message
196 196
 	 * @param array|object $forms
197 197
 	 */
198 198
 	private static function manage( $message = '', $forms = array() ) {
199
-        $frm_style = new FrmStyle();
200
-        $styles = $frm_style->get_all();
201
-        $default_style = $frm_style->get_default_style($styles);
199
+		$frm_style = new FrmStyle();
200
+		$styles = $frm_style->get_all();
201
+		$default_style = $frm_style->get_default_style($styles);
202 202
 
203
-        if ( empty($forms) ) {
204
-            $forms = FrmForm::get_published_forms();
205
-        }
203
+		if ( empty($forms) ) {
204
+			$forms = FrmForm::get_published_forms();
205
+		}
206 206
 
207
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
208
-    }
207
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
208
+	}
209 209
 
210
-    private static function manage_styles() {
210
+	private static function manage_styles() {
211 211
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' );
212 212
 		if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) {
213
-            return self::manage();
214
-        }
213
+			return self::manage();
214
+		}
215 215
 
216
-        global $wpdb;
216
+		global $wpdb;
217 217
 
218 218
 		$forms = FrmForm::get_published_forms();
219
-        foreach ( $forms as $form ) {
220
-            if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
221
-                continue;
222
-            }
219
+		foreach ( $forms as $form ) {
220
+			if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
221
+				continue;
222
+			}
223 223
 
224
-            $form->options['custom_style'] = $_POST['style'][ $form->id ];
224
+			$form->options['custom_style'] = $_POST['style'][ $form->id ];
225 225
 
226 226
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
227
-            unset($form);
228
-        }
227
+			unset($form);
228
+		}
229 229
 
230
-        $message = __( 'Your form styles have been saved.', 'formidable' );
231
-        return self::manage($message, $forms);
232
-    }
230
+		$message = __( 'Your form styles have been saved.', 'formidable' );
231
+		return self::manage($message, $forms);
232
+	}
233 233
 
234
-    public static function custom_css( $message = '', $style = null ) {
235
-        wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
236
-        wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
-        wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
234
+	public static function custom_css( $message = '', $style = null ) {
235
+		wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
236
+		wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
+		wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
238 238
 
239
-        if ( ! isset($style) ) {
240
-            $frm_style = new FrmStyle();
241
-            $style = $frm_style->get_default_style();
242
-        }
239
+		if ( ! isset($style) ) {
240
+			$frm_style = new FrmStyle();
241
+			$style = $frm_style->get_default_style();
242
+		}
243 243
 
244
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
245
-    }
244
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
245
+	}
246 246
 
247
-    public static function save_css() {
248
-        $frm_style = new FrmStyle();
247
+	public static function save_css() {
248
+		$frm_style = new FrmStyle();
249 249
 
250
-        $message = '';
250
+		$message = '';
251 251
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' );
252 252
 		$nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' );
253 253
 		if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) {
254
-            $frm_style->update($post_id);
255
-            $message = __( 'Your styling settings have been saved.', 'formidable' );
256
-        }
254
+			$frm_style->update($post_id);
255
+			$message = __( 'Your styling settings have been saved.', 'formidable' );
256
+		}
257 257
 
258
-        return self::custom_css($message);
259
-    }
258
+		return self::custom_css($message);
259
+	}
260 260
 
261
-    public static function route() {
261
+	public static function route() {
262 262
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
263 263
 
264
-        switch ( $action ) {
265
-            case 'edit':
266
-            case 'save':
267
-            case 'manage':
268
-            case 'manage_styles':
269
-            case 'custom_css':
270
-            case 'save_css':
264
+		switch ( $action ) {
265
+			case 'edit':
266
+			case 'save':
267
+			case 'manage':
268
+			case 'manage_styles':
269
+			case 'custom_css':
270
+			case 'save_css':
271 271
 				return self::$action();
272
-            default:
273
-            	do_action( 'frm_style_action_route', $action );
274
-            	if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) {
275
-                	return;
276
-            	}
277
-
278
-                if ( 'new_style' == $action || 'duplicate' == $action ) {
279
-                    return self::$action();
280
-                }
281
-
282
-                return self::edit();
283
-        }
284
-    }
285
-
286
-    public static function reset_styling() {
287
-        check_ajax_referer( 'frm_ajax', 'nonce' );
288
-
289
-        $frm_style = new FrmStyle();
290
-        $defaults = $frm_style->get_defaults();
291
-
292
-        echo json_encode( $defaults );
293
-        wp_die();
294
-    }
295
-
296
-    public static function change_styling() {
297
-        check_ajax_referer( 'frm_ajax', 'nonce' );
298
-
299
-        $frm_style = new FrmStyle();
300
-        $defaults = $frm_style->get_defaults();
301
-
302
-        // remove the # from the colors
303
-        foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
304
-            if ( ! is_array($v) && strpos($v, '#') === 0 ) {
305
-                $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
-            }
307
-        }
308
-
309
-        echo '<style type="text/css">';
310
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
311
-        echo '</style>';
312
-        wp_die();
313
-    }
314
-
315
-    private static function add_meta_boxes() {
316
-
317
-        // setup meta boxes
318
-        $meta_boxes = array(
319
-            'general'           => __( 'General', 'formidable' ),
320
-            'field-labels'      => __( 'Field Labels', 'formidable' ),
321
-            'field-description' => __( 'Field Description', 'formidable' ),
322
-            'field-colors'      => __( 'Field Colors', 'formidable' ),
323
-            'field-sizes'       => __( 'Field Settings', 'formidable' ),
324
-            'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
325
-            'section-fields'    => __( 'Section Fields', 'formidable' ),
326
-            'date-fields'       => __( 'Date Fields', 'formidable' ),
327
-            'buttons'           => __( 'Buttons', 'formidable' ),
328
-            'form-messages'     => __( 'Form Messages', 'formidable' ),
329
-        );
330
-
331
-        foreach ( $meta_boxes as $nicename => $name ) {
332
-            add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
333
-            unset($nicename, $name);
334
-        }
335
-    }
272
+			default:
273
+				do_action( 'frm_style_action_route', $action );
274
+				if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) {
275
+					return;
276
+				}
277
+
278
+				if ( 'new_style' == $action || 'duplicate' == $action ) {
279
+					return self::$action();
280
+				}
281
+
282
+				return self::edit();
283
+		}
284
+	}
285
+
286
+	public static function reset_styling() {
287
+		check_ajax_referer( 'frm_ajax', 'nonce' );
288
+
289
+		$frm_style = new FrmStyle();
290
+		$defaults = $frm_style->get_defaults();
291
+
292
+		echo json_encode( $defaults );
293
+		wp_die();
294
+	}
295
+
296
+	public static function change_styling() {
297
+		check_ajax_referer( 'frm_ajax', 'nonce' );
298
+
299
+		$frm_style = new FrmStyle();
300
+		$defaults = $frm_style->get_defaults();
301
+
302
+		// remove the # from the colors
303
+		foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
304
+			if ( ! is_array($v) && strpos($v, '#') === 0 ) {
305
+				$_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
+			}
307
+		}
308
+
309
+		echo '<style type="text/css">';
310
+		include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
311
+		echo '</style>';
312
+		wp_die();
313
+	}
314
+
315
+	private static function add_meta_boxes() {
316
+
317
+		// setup meta boxes
318
+		$meta_boxes = array(
319
+			'general'           => __( 'General', 'formidable' ),
320
+			'field-labels'      => __( 'Field Labels', 'formidable' ),
321
+			'field-description' => __( 'Field Description', 'formidable' ),
322
+			'field-colors'      => __( 'Field Colors', 'formidable' ),
323
+			'field-sizes'       => __( 'Field Settings', 'formidable' ),
324
+			'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
325
+			'section-fields'    => __( 'Section Fields', 'formidable' ),
326
+			'date-fields'       => __( 'Date Fields', 'formidable' ),
327
+			'buttons'           => __( 'Buttons', 'formidable' ),
328
+			'form-messages'     => __( 'Form Messages', 'formidable' ),
329
+		);
330
+
331
+		foreach ( $meta_boxes as $nicename => $name ) {
332
+			add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
333
+			unset($nicename, $name);
334
+		}
335
+	}
336 336
 
337 337
 	public static function include_style_section( $atts, $sec ) {
338
-        extract($atts);
338
+		extract($atts);
339 339
 		$current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
340
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
341
-    }
340
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
341
+	}
342 342
 
343
-    public static function load_css() {
344
-        header('Content-type: text/css');
343
+	public static function load_css() {
344
+		header('Content-type: text/css');
345 345
 
346
-        $frm_style = new FrmStyle();
347
-        $defaults = $frm_style->get_defaults();
346
+		$frm_style = new FrmStyle();
347
+		$defaults = $frm_style->get_defaults();
348 348
 
349
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
350
-        wp_die();
351
-    }
349
+		include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
350
+		wp_die();
351
+	}
352 352
 
353 353
 	public static function load_saved_css() {
354 354
 		$css = get_transient( 'frmpro_css' );
@@ -357,142 +357,142 @@  discard block
 block discarded – undo
357 357
 		wp_die();
358 358
 	}
359 359
 
360
-    /**
361
-     * Check if the Formidable styling should be loaded,
362
-     * then enqueue it for the footer
363
-     * @since 2.0
364
-     */
365
-    public static function enqueue_style() {
366
-        global $frm_vars;
367
-
368
-        if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) {
369
-            // the CSS has already been loaded
370
-            return;
371
-        }
372
-
373
-        $frm_settings = FrmAppHelper::get_settings();
374
-        if ( $frm_settings->load_style != 'none' ) {
375
-            wp_enqueue_style( 'formidable' );
376
-            $frm_vars['css_loaded'] = true;
377
-        }
378
-    }
379
-
380
-    // Get the stylesheets for the form settings page
381
-    public static function get_style_opts() {
382
-        $frm_style = new FrmStyle();
383
-        $styles = $frm_style->get_all();
384
-
385
-        return $styles;
386
-    }
387
-
388
-    public static function get_form_style( $form = 'default' ) {
389
-        $style = FrmFormsHelper::get_form_style( $form );
390
-
391
-        if ( empty( $style ) || 1 == $style ) {
392
-            $style = 'default';
393
-        }
394
-
395
-        $frm_style = new FrmStyle( $style );
396
-        return $frm_style->get_one();
397
-    }
398
-
399
-    /**
400
-     * @param string $class
401
-     * @param string $style
402
-     */
360
+	/**
361
+	 * Check if the Formidable styling should be loaded,
362
+	 * then enqueue it for the footer
363
+	 * @since 2.0
364
+	 */
365
+	public static function enqueue_style() {
366
+		global $frm_vars;
367
+
368
+		if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) {
369
+			// the CSS has already been loaded
370
+			return;
371
+		}
372
+
373
+		$frm_settings = FrmAppHelper::get_settings();
374
+		if ( $frm_settings->load_style != 'none' ) {
375
+			wp_enqueue_style( 'formidable' );
376
+			$frm_vars['css_loaded'] = true;
377
+		}
378
+	}
379
+
380
+	// Get the stylesheets for the form settings page
381
+	public static function get_style_opts() {
382
+		$frm_style = new FrmStyle();
383
+		$styles = $frm_style->get_all();
384
+
385
+		return $styles;
386
+	}
387
+
388
+	public static function get_form_style( $form = 'default' ) {
389
+		$style = FrmFormsHelper::get_form_style( $form );
390
+
391
+		if ( empty( $style ) || 1 == $style ) {
392
+			$style = 'default';
393
+		}
394
+
395
+		$frm_style = new FrmStyle( $style );
396
+		return $frm_style->get_one();
397
+	}
398
+
399
+	/**
400
+	 * @param string $class
401
+	 * @param string $style
402
+	 */
403 403
 	public static function get_form_style_class( $class, $style ) {
404
-        if ( 1 == $style ) {
405
-            $style = 'default';
406
-        }
404
+		if ( 1 == $style ) {
405
+			$style = 'default';
406
+		}
407 407
 
408
-        $frm_style = new FrmStyle($style);
409
-        $style = $frm_style->get_one();
408
+		$frm_style = new FrmStyle($style);
409
+		$style = $frm_style->get_one();
410 410
 
411
-        if ( $style ) {
412
-            $class .= ' frm_style_'. $style->post_name;
413
-        }
411
+		if ( $style ) {
412
+			$class .= ' frm_style_'. $style->post_name;
413
+		}
414 414
 
415
-        return $class;
416
-    }
415
+		return $class;
416
+	}
417 417
 
418
-    /**
419
-     * @param string $val
420
-     */
418
+	/**
419
+	 * @param string $val
420
+	 */
421 421
 	public static function get_style_val( $val, $form = 'default' ) {
422
-        $style = self::get_form_style($form);
423
-        if ( $style && isset( $style->post_content[ $val ] ) ) {
424
-            return $style->post_content[ $val ];
425
-        }
426
-    }
422
+		$style = self::get_form_style($form);
423
+		if ( $style && isset( $style->post_content[ $val ] ) ) {
424
+			return $style->post_content[ $val ];
425
+		}
426
+	}
427 427
 
428 428
 	public static function show_entry_styles( $default_styles ) {
429
-        $frm_style = new FrmStyle('default');
430
-        $style = $frm_style->get_one();
431
-
432
-        if ( ! $style ) {
433
-            return $default_styles;
434
-        }
435
-
436
-        foreach ( $default_styles as $name => $val ) {
437
-            $setting = $name;
438
-            if ( 'border_width' == $name ) {
439
-                $setting = 'field_border_width';
440
-            } else if ( 'alt_bg_color' == $name ) {
441
-                $setting = 'bg_color_active';
442
-            }
443
-            $default_styles[ $name ] = $style->post_content[ $setting ];
444
-            unset($name, $val);
445
-        }
446
-
447
-        return $default_styles;
448
-    }
429
+		$frm_style = new FrmStyle('default');
430
+		$style = $frm_style->get_one();
431
+
432
+		if ( ! $style ) {
433
+			return $default_styles;
434
+		}
435
+
436
+		foreach ( $default_styles as $name => $val ) {
437
+			$setting = $name;
438
+			if ( 'border_width' == $name ) {
439
+				$setting = 'field_border_width';
440
+			} else if ( 'alt_bg_color' == $name ) {
441
+				$setting = 'bg_color_active';
442
+			}
443
+			$default_styles[ $name ] = $style->post_content[ $setting ];
444
+			unset($name, $val);
445
+		}
446
+
447
+		return $default_styles;
448
+	}
449 449
 
450 450
 	public static function &important_style( $important, $field ) {
451
-        $important = self::get_style_val('important_style', $field['form_id']);
452
-        return $important;
453
-    }
451
+		$important = self::get_style_val('important_style', $field['form_id']);
452
+		return $important;
453
+	}
454 454
 
455
-    /**
456
-     * Fallback for WP < 3.6
457
-     */
458
-    public static function do_accordion_sections( $screen, $context, $object ) {
459
-        if ( function_exists( 'do_accordion_sections' ) ) {
460
-            return do_accordion_sections( $screen, $context, $object );
461
-        }
455
+	/**
456
+	 * Fallback for WP < 3.6
457
+	 */
458
+	public static function do_accordion_sections( $screen, $context, $object ) {
459
+		if ( function_exists( 'do_accordion_sections' ) ) {
460
+			return do_accordion_sections( $screen, $context, $object );
461
+		}
462 462
 
463
-    	global $wp_meta_boxes;
463
+		global $wp_meta_boxes;
464 464
 
465
-        $screen = 'formidable_page_formidable-styles';
466
-        $screen = convert_to_screen( $screen );
465
+		$screen = 'formidable_page_formidable-styles';
466
+		$screen = convert_to_screen( $screen );
467 467
 
468
-    	$page = $screen->id;
468
+		$page = $screen->id;
469 469
 
470
-    	$hidden = get_hidden_meta_boxes( $screen );
471
-    	?>
470
+		$hidden = get_hidden_meta_boxes( $screen );
471
+		?>
472 472
     	<div id="side-sortables" class="accordion-container">
473 473
     	<?php
474
-    	$i = 0;
475
-    	$first_open = false;
476
-    	do {
474
+		$i = 0;
475
+		$first_open = false;
476
+		do {
477 477
 			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
478 478
 				break;
479 479
 			}
480 480
 
481
-    		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
482
-    			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
483
-    				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
-    					if ( false == $box || ! $box['title'] ) {
485
-    						continue;
481
+			foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
482
+				if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
483
+					foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
+						if ( false == $box || ! $box['title'] ) {
485
+							continue;
486 486
 						}
487 487
 
488
-    					$i++;
489
-    					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
488
+						$i++;
489
+						$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
490 490
 
491
-    					if ( ! $first_open && empty( $hidden_class ) ) {
492
-    						$first_open = true;
493
-    					}
491
+						if ( ! $first_open && empty( $hidden_class ) ) {
492
+							$first_open = true;
493
+						}
494 494
 
495
-    					?>
495
+						?>
496 496
 						<div class="postbox <?php echo esc_attr( $box['id'] ); ?>">
497 497
 						<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div>
498 498
                         <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3>
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
     						</div><!-- .accordion-section-content -->
504 504
     					</div><!-- .postbox -->
505 505
     					<?php
506
-    				}
507
-    			}
508
-    		}
509
-    	} while ( 0 );
510
-    	?>
506
+					}
507
+				}
508
+			}
509
+		} while ( 0 );
510
+		?>
511 511
     	</div><!-- .accordion-container -->
512 512
     	<?php
513
-    	return $i;
514
-    }
513
+		return $i;
514
+	}
515 515
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -5,68 +5,68 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        global $frm_vars;
10
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		global $frm_vars;
10
+		$values = array();
11 11
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
12
-            $values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
13
-        }
14
-
15
-        $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
18
-        }
19
-
20
-        foreach ( (array) $fields as $field ) {
21
-            $new_value = self::get_field_value_for_new_entry( $field, $reset );
22
-
23
-            $field_array = array(
24
-                'id' => $field->id,
25
-                'value' => $new_value,
26
-                'default_value' => $field->default_value,
27
-                'name' => $field->name,
28
-                'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
-                'options' => $field->options,
31
-                'required' => $field->required,
32
-                'field_key' => $field->field_key,
33
-                'field_order' => $field->field_order,
34
-                'form_id' => $field->form_id,
12
+			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
13
+		}
14
+
15
+		$values['fields'] = array();
16
+		if ( empty($fields) ) {
17
+			return apply_filters('frm_setup_new_entry', $values);
18
+		}
19
+
20
+		foreach ( (array) $fields as $field ) {
21
+			$new_value = self::get_field_value_for_new_entry( $field, $reset );
22
+
23
+			$field_array = array(
24
+				'id' => $field->id,
25
+				'value' => $new_value,
26
+				'default_value' => $field->default_value,
27
+				'name' => $field->name,
28
+				'description' => $field->description,
29
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
+				'options' => $field->options,
31
+				'required' => $field->required,
32
+				'field_key' => $field->field_key,
33
+				'field_order' => $field->field_order,
34
+				'form_id' => $field->form_id,
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36
-            );
36
+			);
37 37
 
38
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
-            $opt_defaults['required_indicator'] = '';
38
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+			$opt_defaults['required_indicator'] = '';
40 40
 			$opt_defaults['original_type'] = $field->type;
41 41
 
42 42
 			foreach ( $opt_defaults as $opt => $default_opt ) {
43
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
-                unset($opt, $default_opt);
45
-            }
43
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
+				unset($opt, $default_opt);
45
+			}
46 46
 
47
-            unset($opt_defaults);
47
+			unset($opt_defaults);
48 48
 
49
-            if ( $field_array['custom_html'] == '' ) {
50
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
-            }
49
+			if ( $field_array['custom_html'] == '' ) {
50
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+			}
52 52
 
53
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
54
-            $field_array = array_merge( $field->field_options, $field_array );
53
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
54
+			$field_array = array_merge( $field->field_options, $field_array );
55 55
 
56
-            $values['fields'][] = $field_array;
56
+			$values['fields'][] = $field_array;
57 57
 
58
-            if ( ! $form || ! isset($form->id) ) {
59
-                $form = FrmForm::getOne($field->form_id);
60
-            }
61
-        }
58
+			if ( ! $form || ! isset($form->id) ) {
59
+				$form = FrmForm::getOne($field->form_id);
60
+			}
61
+		}
62 62
 
63
-        $form->options = maybe_unserialize($form->options);
64
-        if ( is_array($form->options) ) {
65
-            foreach ( $form->options as $opt => $value ) {
66
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
-                unset($opt, $value);
68
-            }
69
-        }
63
+		$form->options = maybe_unserialize($form->options);
64
+		if ( is_array($form->options) ) {
65
+			foreach ( $form->options as $opt => $value ) {
66
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
+				unset($opt, $value);
68
+			}
69
+		}
70 70
 
71 71
 		$form_defaults = FrmFormsHelper::get_default_opts();
72 72
 
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 		$values = array_merge( $form_defaults, $values );
77 77
 
78 78
 		return apply_filters( 'frm_setup_new_entry', $values );
79
-    }
79
+	}
80 80
 
81 81
 	/**
82
-	* Set the value for each field
83
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
84
-	*
85
-	* @since 2.0.13
86
-	*
87
-	* @param object $field - this is passed by reference since it is an object
88
-	* @param boolean $reset
89
-	* @return string|array $new_value
90
-	*/
82
+	 * Set the value for each field
83
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
84
+	 *
85
+	 * @since 2.0.13
86
+	 *
87
+	 * @param object $field - this is passed by reference since it is an object
88
+	 * @param boolean $reset
89
+	 * @return string|array $new_value
90
+	 */
91 91
 	private static function get_field_value_for_new_entry( $field, $reset ) {
92 92
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
93 93
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 
119 119
 	public static function setup_edit_vars( $values, $record ) {
120 120
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
121
-        $values['form_id'] = $record->form_id;
122
-        $values['is_draft'] = $record->is_draft;
123
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
124
-    }
121
+		$values['form_id'] = $record->form_id;
122
+		$values['is_draft'] = $record->is_draft;
123
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
124
+	}
125 125
 
126
-    public static function get_admin_params( $form = null ) {
126
+	public static function get_admin_params( $form = null ) {
127 127
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
128 128
 		return FrmForm::set_current_form( $form );
129
-    }
129
+	}
130 130
 
131 131
 	public static function set_current_form( $form_id ) {
132 132
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -138,280 +138,280 @@  discard block
 block discarded – undo
138 138
 		return FrmForm::get_current_form( $form_id );
139 139
 	}
140 140
 
141
-    public static function get_current_form_id() {
141
+	public static function get_current_form_id() {
142 142
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
143 143
 		return FrmForm::get_current_form_id();
144
-    }
144
+	}
145 145
 
146
-    public static function maybe_get_entry( &$entry ) {
146
+	public static function maybe_get_entry( &$entry ) {
147 147
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
148 148
 		FrmEntry::maybe_get_entry( $entry );
149
-    }
149
+	}
150 150
 
151 151
 	public static function replace_default_message( $message, $atts ) {
152
-        if ( strpos($message, '[default-message') === false &&
153
-            strpos($message, '[default_message') === false &&
154
-            ! empty( $message ) ) {
155
-            return $message;
156
-        }
157
-
158
-        if ( empty($message) ) {
159
-            $message = '[default-message]';
160
-        }
161
-
162
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
163
-
164
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
165
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
166
-            if ( $add_atts ) {
167
-                $this_atts = array_merge($atts, $add_atts);
168
-            } else {
169
-                $this_atts = $atts;
170
-            }
152
+		if ( strpos($message, '[default-message') === false &&
153
+			strpos($message, '[default_message') === false &&
154
+			! empty( $message ) ) {
155
+			return $message;
156
+		}
157
+
158
+		if ( empty($message) ) {
159
+			$message = '[default-message]';
160
+		}
161
+
162
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
163
+
164
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
165
+			$add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
166
+			if ( $add_atts ) {
167
+				$this_atts = array_merge($atts, $add_atts);
168
+			} else {
169
+				$this_atts = $atts;
170
+			}
171 171
 
172 172
 			$default = FrmEntryFormat::show_entry( $this_atts );
173 173
 
174
-            // Add the default message
175
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
176
-        }
174
+			// Add the default message
175
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
176
+		}
177 177
 
178
-        return $message;
179
-    }
178
+		return $message;
179
+	}
180 180
 
181 181
 	public static function prepare_display_value( $entry, $field, $atts ) {
182 182
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
183
-        if ( FrmAppHelper::pro_is_installed() ) {
183
+		if ( FrmAppHelper::pro_is_installed() ) {
184 184
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
185
-        }
185
+		}
186 186
 
187
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
-            return self::display_value($field_value, $field, $atts);
189
-        }
187
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
+			return self::display_value($field_value, $field, $atts);
189
+		}
190 190
 
191
-        // this is an embeded form
192
-        $val = '';
191
+		// this is an embeded form
192
+		$val = '';
193 193
 
194
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
195
-            //this is a repeating section
194
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
195
+			//this is a repeating section
196 196
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197
-        } else {
198
-            // get all values for this field
199
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
197
+		} else {
198
+			// get all values for this field
199
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
200 200
 
201
-            if ( $child_values ) {
202
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203
-	        }
204
-	    }
201
+			if ( $child_values ) {
202
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203
+			}
204
+		}
205 205
 
206
-	    $field_value = array();
206
+		$field_value = array();
207 207
 
208
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209
-            return $val;
210
-        }
208
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209
+			return $val;
210
+		}
211 211
 
212
-        foreach ( $child_entries as $child_entry ) {
213
-            $atts['item_id'] = $child_entry->id;
214
-            $atts['post_id'] = $child_entry->post_id;
212
+		foreach ( $child_entries as $child_entry ) {
213
+			$atts['item_id'] = $child_entry->id;
214
+			$atts['post_id'] = $child_entry->post_id;
215 215
 
216
-            // get the value for this field -- check for post values as well
217
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
216
+			// get the value for this field -- check for post values as well
217
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
218 218
 
219
-            if ( $entry_val ) {
220
-                // foreach entry get display_value
221
-                $field_value[] = self::display_value($entry_val, $field, $atts);
222
-            }
219
+			if ( $entry_val ) {
220
+				// foreach entry get display_value
221
+				$field_value[] = self::display_value($entry_val, $field, $atts);
222
+			}
223 223
 
224
-            unset($child_entry);
225
-        }
224
+			unset($child_entry);
225
+		}
226 226
 
227
-        $val = implode(', ', (array) $field_value );
227
+		$val = implode(', ', (array) $field_value );
228 228
 		$val = wp_kses_post( $val );
229 229
 
230
-        return $val;
231
-    }
230
+		return $val;
231
+	}
232 232
 
233
-    /**
234
-     * Prepare the saved value for display
235
-     * @return string
236
-     */
233
+	/**
234
+	 * Prepare the saved value for display
235
+	 * @return string
236
+	 */
237 237
 	public static function display_value( $value, $field, $atts = array() ) {
238 238
 
239
-        $defaults = array(
240
-            'type' => '', 'html' => false, 'show_filename' => true,
241
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
242
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
239
+		$defaults = array(
240
+			'type' => '', 'html' => false, 'show_filename' => true,
241
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
242
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
243 243
 			'return_array' => false,
244
-        );
244
+		);
245 245
 
246
-        $atts = wp_parse_args( $atts, $defaults );
247
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
246
+		$atts = wp_parse_args( $atts, $defaults );
247
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
248 248
 
249
-        if ( ! isset($field->field_options['post_field']) ) {
250
-            $field->field_options['post_field'] = '';
251
-        }
249
+		if ( ! isset($field->field_options['post_field']) ) {
250
+			$field->field_options['post_field'] = '';
251
+		}
252 252
 
253
-        if ( ! isset($field->field_options['custom_field']) ) {
254
-            $field->field_options['custom_field'] = '';
255
-        }
253
+		if ( ! isset($field->field_options['custom_field']) ) {
254
+			$field->field_options['custom_field'] = '';
255
+		}
256 256
 
257
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258
-            $atts['pre_truncate'] = $atts['truncate'];
259
-            $atts['truncate'] = true;
260
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
257
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258
+			$atts['pre_truncate'] = $atts['truncate'];
259
+			$atts['truncate'] = true;
260
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
261 261
 
262
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
263
-            $atts['truncate'] = $atts['pre_truncate'];
264
-        }
262
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
263
+			$atts['truncate'] = $atts['pre_truncate'];
264
+		}
265 265
 
266
-        if ( $value == '' ) {
267
-            return $value;
268
-        }
266
+		if ( $value == '' ) {
267
+			return $value;
268
+		}
269 269
 
270
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
270
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
271 271
 
272
-        $new_value = '';
272
+		$new_value = '';
273 273
 
274
-        if ( is_array($value) && $atts['type'] != 'file' ) {
275
-            foreach ( $value as $val ) {
276
-                if ( is_array($val) ) {
274
+		if ( is_array($value) && $atts['type'] != 'file' ) {
275
+			foreach ( $value as $val ) {
276
+				if ( is_array($val) ) {
277 277
 					//TODO: add options for display (li or ,)
278
-                    $new_value .= implode($atts['sep'], $val);
279
-                    if ( $atts['type'] != 'data' ) {
280
-                        $new_value .= '<br/>';
281
-                    }
282
-                }
283
-                unset($val);
284
-            }
285
-        }
286
-
287
-        if ( ! empty($new_value) ) {
288
-            $value = $new_value;
289
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
-            $value = implode($atts['sep'], $value);
291
-        }
292
-
293
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
-            $value = FrmAppHelper::truncate($value, 50);
295
-        }
278
+					$new_value .= implode($atts['sep'], $val);
279
+					if ( $atts['type'] != 'data' ) {
280
+						$new_value .= '<br/>';
281
+					}
282
+				}
283
+				unset($val);
284
+			}
285
+		}
286
+
287
+		if ( ! empty($new_value) ) {
288
+			$value = $new_value;
289
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
+			$value = implode($atts['sep'], $value);
291
+		}
292
+
293
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
+			$value = FrmAppHelper::truncate($value, 50);
295
+		}
296 296
 
297 297
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
298 298
 			$value = wp_kses_post( $value );
299 299
 		}
300 300
 
301
-        return apply_filters('frm_display_value', $value, $field, $atts);
302
-    }
301
+		return apply_filters('frm_display_value', $value, $field, $atts);
302
+	}
303 303
 
304 304
 	public static function set_posted_value( $field, $value, $args ) {
305
-        // If validating a field with "other" opt, set back to prev value now
306
-        if ( isset( $args['other'] ) && $args['other'] ) {
307
-            $value = $args['temp_value'];
308
-        }
309
-        if ( empty($args['parent_field_id']) ) {
310
-            $_POST['item_meta'][ $field->id ] = $value;
311
-        } else {
312
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
313
-        }
314
-    }
305
+		// If validating a field with "other" opt, set back to prev value now
306
+		if ( isset( $args['other'] ) && $args['other'] ) {
307
+			$value = $args['temp_value'];
308
+		}
309
+		if ( empty($args['parent_field_id']) ) {
310
+			$_POST['item_meta'][ $field->id ] = $value;
311
+		} else {
312
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
313
+		}
314
+	}
315 315
 
316 316
 	public static function get_posted_value( $field, &$value, $args ) {
317 317
 		$field_id = is_object( $field ) ? $field->id : $field;
318 318
 
319
-        if ( empty($args['parent_field_id']) ) {
320
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
321
-        } else {
322
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
323
-        }
324
-    }
325
-
326
-    /**
327
-    * Check if field has an "Other" option and if any other values are posted
328
-    *
329
-    * @since 2.0
330
-    *
331
-    * @param object $field
332
-    * @param string|array $value
333
-    * @param array $args
334
-    */
335
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
336
-        $args['other'] = false;
337
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
338
-            return;
339
-        }
340
-
341
-        // Get other value for fields in repeating section
342
-        self::set_other_repeating_vals( $field, $value, $args );
343
-
344
-        // Check if there are any posted "Other" values
319
+		if ( empty($args['parent_field_id']) ) {
320
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
321
+		} else {
322
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
323
+		}
324
+	}
325
+
326
+	/**
327
+	 * Check if field has an "Other" option and if any other values are posted
328
+	 *
329
+	 * @since 2.0
330
+	 *
331
+	 * @param object $field
332
+	 * @param string|array $value
333
+	 * @param array $args
334
+	 */
335
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
336
+		$args['other'] = false;
337
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
338
+			return;
339
+		}
340
+
341
+		// Get other value for fields in repeating section
342
+		self::set_other_repeating_vals( $field, $value, $args );
343
+
344
+		// Check if there are any posted "Other" values
345 345
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
346 346
 
347
-            // Save original value
348
-            $args['temp_value'] = $value;
349
-            $args['other'] = true;
350
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
351
-
352
-            // Set the validation value now
353
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
354
-        }
355
-    }
356
-
357
-    /**
358
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
359
-    *
360
-    * @since 2.0
361
-    *
362
-    * @param object $field
363
-    * @param string|array $value
364
-    * @param array $args
365
-    */
366
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
367
-        if ( ! $args['parent_field_id'] ) {
368
-            return;
369
-        }
370
-
371
-        // Check if there are any other posted "other" values for this field
347
+			// Save original value
348
+			$args['temp_value'] = $value;
349
+			$args['other'] = true;
350
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
351
+
352
+			// Set the validation value now
353
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
354
+		}
355
+	}
356
+
357
+	/**
358
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
359
+	 *
360
+	 * @since 2.0
361
+	 *
362
+	 * @param object $field
363
+	 * @param string|array $value
364
+	 * @param array $args
365
+	 */
366
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
367
+		if ( ! $args['parent_field_id'] ) {
368
+			return;
369
+		}
370
+
371
+		// Check if there are any other posted "other" values for this field
372 372
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
373
-            // Save original value
374
-            $args['temp_value'] = $value;
375
-            $args['other'] = true;
376
-
377
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
378
-
379
-            // Set the validation value now
380
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
381
-        }
382
-    }
383
-
384
-    /**
385
-    * Modify value used for validation
386
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
387
-    * It also adds any text from the free text fields to the value
388
-    *
389
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
390
-    *
391
-    * @since 2.0
392
-    *
393
-    * @param string|array $value
394
-    * @param string|array $other_vals (usually of posted values)
395
-    * @param object $field
396
-    * @param array $args
397
-    */
398
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
399
-        // Checkboxes and multi-select dropdowns
400
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
401
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
402
-            $value = array_merge( $value, $other_vals );
403
-            $value = array_filter( $value );
404
-            if ( count( $value ) == 0 ) {
405
-                $value = '';
406
-            }
407
-        } else {
373
+			// Save original value
374
+			$args['temp_value'] = $value;
375
+			$args['other'] = true;
376
+
377
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
378
+
379
+			// Set the validation value now
380
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
381
+		}
382
+	}
383
+
384
+	/**
385
+	 * Modify value used for validation
386
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
387
+	 * It also adds any text from the free text fields to the value
388
+	 *
389
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
390
+	 *
391
+	 * @since 2.0
392
+	 *
393
+	 * @param string|array $value
394
+	 * @param string|array $other_vals (usually of posted values)
395
+	 * @param object $field
396
+	 * @param array $args
397
+	 */
398
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
399
+		// Checkboxes and multi-select dropdowns
400
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
401
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
402
+			$value = array_merge( $value, $other_vals );
403
+			$value = array_filter( $value );
404
+			if ( count( $value ) == 0 ) {
405
+				$value = '';
406
+			}
407
+		} else {
408 408
 			// Radio and dropdowns
409
-            $other_key = array_filter( array_keys($field->options), 'is_string');
410
-            $other_key = reset( $other_key );
409
+			$other_key = array_filter( array_keys($field->options), 'is_string');
410
+			$other_key = reset( $other_key );
411 411
 
412
-            // Multi-select dropdown
413
-            if ( is_array( $value ) ) {
414
-                $o_key = array_search( $field->options[ $other_key ], $value );
412
+			// Multi-select dropdown
413
+			if ( is_array( $value ) ) {
414
+				$o_key = array_search( $field->options[ $other_key ], $value );
415 415
 
416 416
 				if ( $o_key !== false ) {
417 417
 					// Modify the original value so other key will be preserved
@@ -426,20 +426,20 @@  discard block
 block discarded – undo
426 426
 					$args['temp_value'] = $value;
427 427
 					$value[ $other_key ] = reset( $other_vals );
428 428
 				}
429
-            } else if ( $field->options[ $other_key ] == $value ) {
430
-                $value = $other_vals;
431
-            }
432
-        }
433
-    }
429
+			} else if ( $field->options[ $other_key ] == $value ) {
430
+				$value = $other_vals;
431
+			}
432
+		}
433
+	}
434 434
 
435 435
 	public static function enqueue_scripts( $params ) {
436 436
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
437 437
 		return FrmFormsController::enqueue_scripts( $params );
438 438
 	}
439 439
 
440
-    // Add submitted values to a string for spam checking
440
+	// Add submitted values to a string for spam checking
441 441
 	public static function entry_array_to_string( $values ) {
442
-        $content = '';
442
+		$content = '';
443 443
 		foreach ( $values['item_meta'] as $val ) {
444 444
 			if ( $content != '' ) {
445 445
 				$content .= "\n\n";
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
 
448 448
 			if ( is_array($val) ) {
449 449
 				$val = FrmAppHelper::array_flatten( $val );
450
-			    $val = implode(',', $val);
450
+				$val = implode(',', $val);
451 451
 			}
452 452
 
453 453
 			$content .= $val;
454 454
 		}
455 455
 
456 456
 		return $content;
457
-    }
457
+	}
458 458
 
459 459
 	public static function fill_entry_values( $atts, $f, array &$values ) {
460 460
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 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
 
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
         global $frm_vars;
10 10
         $values = array();
11 11
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
12
-            $values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
12
+            $values[$var] = FrmAppHelper::get_post_param( $var, $default );
13 13
         }
14 14
 
15 15
         $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
16
+        if ( empty( $fields ) ) {
17
+            return apply_filters( 'frm_setup_new_entry', $values );
18 18
         }
19 19
 
20 20
         foreach ( (array) $fields as $field ) {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                 'default_value' => $field->default_value,
27 27
                 'name' => $field->name,
28 28
                 'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
30 30
                 'options' => $field->options,
31 31
                 'required' => $field->required,
32 32
                 'field_key' => $field->field_key,
@@ -35,43 +35,43 @@  discard block
 block discarded – undo
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36 36
             );
37 37
 
38
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
38
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
39 39
             $opt_defaults['required_indicator'] = '';
40 40
 			$opt_defaults['original_type'] = $field->type;
41 41
 
42 42
 			foreach ( $opt_defaults as $opt => $default_opt ) {
43
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
-                unset($opt, $default_opt);
43
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
44
+                unset( $opt, $default_opt );
45 45
             }
46 46
 
47
-            unset($opt_defaults);
47
+            unset( $opt_defaults );
48 48
 
49 49
             if ( $field_array['custom_html'] == '' ) {
50
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
50
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
51 51
             }
52 52
 
53
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
53
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field );
54 54
             $field_array = array_merge( $field->field_options, $field_array );
55 55
 
56 56
             $values['fields'][] = $field_array;
57 57
 
58
-            if ( ! $form || ! isset($form->id) ) {
59
-                $form = FrmForm::getOne($field->form_id);
58
+            if ( ! $form || ! isset( $form->id ) ) {
59
+                $form = FrmForm::getOne( $field->form_id );
60 60
             }
61 61
         }
62 62
 
63
-        $form->options = maybe_unserialize($form->options);
64
-        if ( is_array($form->options) ) {
63
+        $form->options = maybe_unserialize( $form->options );
64
+        if ( is_array( $form->options ) ) {
65 65
             foreach ( $form->options as $opt => $value ) {
66
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
-                unset($opt, $value);
66
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
67
+                unset( $opt, $value );
68 68
             }
69 69
         }
70 70
 
71 71
 		$form_defaults = FrmFormsHelper::get_default_opts();
72 72
 
73 73
 		$frm_settings = FrmAppHelper::get_settings();
74
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
74
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
75 75
 
76 76
 		$values = array_merge( $form_defaults, $values );
77 77
 
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 		$return_array = FrmField::is_field_with_multiple_values( $field );
94 94
 
95 95
 		// Do any shortcodes in default value and allow customization of default value
96
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
96
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
97 97
 		// Calls FrmProFieldsHelper::get_default_value
98 98
 
99 99
 		$new_value = $field->default_value;
100 100
 
101
-		if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) {
101
+		if ( ! $reset && $_POST && isset( $_POST['item_meta'][$field->id] ) ) {
102 102
 			// If value was posted, get it
103 103
 
104
-			$new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] );
104
+			$new_value = stripslashes_deep( $_POST['item_meta'][$field->id] );
105 105
 
106 106
 		} else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
107 107
 			// If clear on focus is selected, the value should be blank (unless it was posted, of course)
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 
112 112
 		if ( ! is_array( $new_value ) ) {
113
-			$new_value = str_replace('"', '&quot;', $new_value);
113
+			$new_value = str_replace( '"', '&quot;', $new_value );
114 114
 		}
115 115
 
116 116
 		return $new_value;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
121 121
         $values['form_id'] = $record->form_id;
122 122
         $values['is_draft'] = $record->is_draft;
123
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
123
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
124 124
     }
125 125
 
126 126
     public static function get_admin_params( $form = null ) {
@@ -149,22 +149,22 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
 	public static function replace_default_message( $message, $atts ) {
152
-        if ( strpos($message, '[default-message') === false &&
153
-            strpos($message, '[default_message') === false &&
152
+        if ( strpos( $message, '[default-message' ) === false &&
153
+            strpos( $message, '[default_message' ) === false &&
154 154
             ! empty( $message ) ) {
155 155
             return $message;
156 156
         }
157 157
 
158
-        if ( empty($message) ) {
158
+        if ( empty( $message ) ) {
159 159
             $message = '[default-message]';
160 160
         }
161 161
 
162
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
162
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
163 163
 
164 164
         foreach ( $shortcodes[0] as $short_key => $tag ) {
165
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
165
+            $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
166 166
             if ( $add_atts ) {
167
-                $this_atts = array_merge($atts, $add_atts);
167
+                $this_atts = array_merge( $atts, $add_atts );
168 168
             } else {
169 169
                 $this_atts = $atts;
170 170
             }
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 			$default = FrmEntryFormat::show_entry( $this_atts );
173 173
 
174 174
             // Add the default message
175
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
175
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
176 176
         }
177 177
 
178 178
         return $message;
179 179
     }
180 180
 
181 181
 	public static function prepare_display_value( $entry, $field, $atts ) {
182
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
182
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
183 183
         if ( FrmAppHelper::pro_is_installed() ) {
184 184
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
185 185
         }
186 186
 
187
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
-            return self::display_value($field_value, $field, $atts);
187
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
188
+            return self::display_value( $field_value, $field, $atts );
189 189
         }
190 190
 
191 191
         // this is an embeded form
192 192
         $val = '';
193 193
 
194
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
194
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
195 195
             //this is a repeating section
196 196
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197 197
         } else {
198 198
             // get all values for this field
199
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
199
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
200 200
 
201 201
             if ( $child_values ) {
202 202
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
 	    $field_value = array();
207 207
 
208
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
208
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209 209
             return $val;
210 210
         }
211 211
 
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
             $atts['post_id'] = $child_entry->post_id;
215 215
 
216 216
             // get the value for this field -- check for post values as well
217
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
217
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
218 218
 
219 219
             if ( $entry_val ) {
220 220
                 // foreach entry get display_value
221
-                $field_value[] = self::display_value($entry_val, $field, $atts);
221
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
222 222
             }
223 223
 
224
-            unset($child_entry);
224
+            unset( $child_entry );
225 225
         }
226 226
 
227
-        $val = implode(', ', (array) $field_value );
227
+        $val = implode( ', ', (array) $field_value );
228 228
 		$val = wp_kses_post( $val );
229 229
 
230 230
         return $val;
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
         );
245 245
 
246 246
         $atts = wp_parse_args( $atts, $defaults );
247
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
247
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
248 248
 
249
-        if ( ! isset($field->field_options['post_field']) ) {
249
+        if ( ! isset( $field->field_options['post_field'] ) ) {
250 250
             $field->field_options['post_field'] = '';
251 251
         }
252 252
 
253
-        if ( ! isset($field->field_options['custom_field']) ) {
253
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
254 254
             $field->field_options['custom_field'] = '';
255 255
         }
256 256
 
257 257
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258 258
             $atts['pre_truncate'] = $atts['truncate'];
259 259
             $atts['truncate'] = true;
260
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
260
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
261 261
 
262
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
262
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
263 263
             $atts['truncate'] = $atts['pre_truncate'];
264 264
         }
265 265
 
@@ -267,38 +267,38 @@  discard block
 block discarded – undo
267 267
             return $value;
268 268
         }
269 269
 
270
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
270
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
271 271
 
272 272
         $new_value = '';
273 273
 
274
-        if ( is_array($value) && $atts['type'] != 'file' ) {
274
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
275 275
             foreach ( $value as $val ) {
276
-                if ( is_array($val) ) {
276
+                if ( is_array( $val ) ) {
277 277
 					//TODO: add options for display (li or ,)
278
-                    $new_value .= implode($atts['sep'], $val);
278
+                    $new_value .= implode( $atts['sep'], $val );
279 279
                     if ( $atts['type'] != 'data' ) {
280 280
                         $new_value .= '<br/>';
281 281
                     }
282 282
                 }
283
-                unset($val);
283
+                unset( $val );
284 284
             }
285 285
         }
286 286
 
287
-        if ( ! empty($new_value) ) {
287
+        if ( ! empty( $new_value ) ) {
288 288
             $value = $new_value;
289
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
-            $value = implode($atts['sep'], $value);
289
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
+            $value = implode( $atts['sep'], $value );
291 291
         }
292 292
 
293 293
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
-            $value = FrmAppHelper::truncate($value, 50);
294
+            $value = FrmAppHelper::truncate( $value, 50 );
295 295
         }
296 296
 
297 297
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
298 298
 			$value = wp_kses_post( $value );
299 299
 		}
300 300
 
301
-        return apply_filters('frm_display_value', $value, $field, $atts);
301
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
302 302
     }
303 303
 
304 304
 	public static function set_posted_value( $field, $value, $args ) {
@@ -306,20 +306,20 @@  discard block
 block discarded – undo
306 306
         if ( isset( $args['other'] ) && $args['other'] ) {
307 307
             $value = $args['temp_value'];
308 308
         }
309
-        if ( empty($args['parent_field_id']) ) {
310
-            $_POST['item_meta'][ $field->id ] = $value;
309
+        if ( empty( $args['parent_field_id'] ) ) {
310
+            $_POST['item_meta'][$field->id] = $value;
311 311
         } else {
312
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
312
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
313 313
         }
314 314
     }
315 315
 
316 316
 	public static function get_posted_value( $field, &$value, $args ) {
317 317
 		$field_id = is_object( $field ) ? $field->id : $field;
318 318
 
319
-        if ( empty($args['parent_field_id']) ) {
320
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
319
+        if ( empty( $args['parent_field_id'] ) ) {
320
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
321 321
         } else {
322
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
322
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
323 323
         }
324 324
     }
325 325
 
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
         self::set_other_repeating_vals( $field, $value, $args );
343 343
 
344 344
         // Check if there are any posted "Other" values
345
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
345
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
346 346
 
347 347
             // Save original value
348 348
             $args['temp_value'] = $value;
349 349
             $args['other'] = true;
350
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
350
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
351 351
 
352 352
             // Set the validation value now
353 353
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
         }
370 370
 
371 371
         // Check if there are any other posted "other" values for this field
372
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
372
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
373 373
             // Save original value
374 374
             $args['temp_value'] = $value;
375 375
             $args['other'] = true;
376 376
 
377
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
377
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
378 378
 
379 379
             // Set the validation value now
380 380
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -406,27 +406,27 @@  discard block
 block discarded – undo
406 406
             }
407 407
         } else {
408 408
 			// Radio and dropdowns
409
-            $other_key = array_filter( array_keys($field->options), 'is_string');
409
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
410 410
             $other_key = reset( $other_key );
411 411
 
412 412
             // Multi-select dropdown
413 413
             if ( is_array( $value ) ) {
414
-                $o_key = array_search( $field->options[ $other_key ], $value );
414
+                $o_key = array_search( $field->options[$other_key], $value );
415 415
 
416 416
 				if ( $o_key !== false ) {
417 417
 					// Modify the original value so other key will be preserved
418
-					$value[ $other_key ] = $value[ $o_key ];
418
+					$value[$other_key] = $value[$o_key];
419 419
 
420 420
 					// By default, the array keys will be numeric for multi-select dropdowns
421 421
 					// If going backwards and forwards between pages, the array key will match the other key
422 422
 					if ( $o_key != $other_key ) {
423
-						unset( $value[ $o_key ] );
423
+						unset( $value[$o_key] );
424 424
 					}
425 425
 
426 426
 					$args['temp_value'] = $value;
427
-					$value[ $other_key ] = reset( $other_vals );
427
+					$value[$other_key] = reset( $other_vals );
428 428
 				}
429
-            } else if ( $field->options[ $other_key ] == $value ) {
429
+            } else if ( $field->options[$other_key] == $value ) {
430 430
                 $value = $other_vals;
431 431
             }
432 432
         }
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 				$content .= "\n\n";
446 446
 			}
447 447
 
448
-			if ( is_array($val) ) {
448
+			if ( is_array( $val ) ) {
449 449
 				$val = FrmAppHelper::array_flatten( $val );
450
-			    $val = implode(',', $val);
450
+			    $val = implode( ',', $val );
451 451
 			}
452 452
 
453 453
 			$content .= $val;
@@ -492,6 +492,6 @@  discard block
 block discarded – undo
492 492
 	}
493 493
 
494 494
 	public static function entries_dropdown() {
495
-		_deprecated_function( __FUNCTION__, '1.07.09');
495
+		_deprecated_function( __FUNCTION__, '1.07.09' );
496 496
 	}
497 497
 }
Please login to merge, or discard this patch.