Completed
Push — master ( 34a6d7...6a5510 )
by Jamie
04:20
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   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public static function plugin_folder() {
26
-        return basename(self::plugin_path());
26
+        return basename( self::plugin_path() );
27 27
     }
28 28
 
29 29
     public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
30
+        return dirname( dirname( dirname( __FILE__ ) ) );
31 31
     }
32 32
 
33 33
     public static function plugin_url() {
34 34
         //prevously FRM_URL constant
35
-        return plugins_url( '', self::plugin_path() .'/formidable.php' );
35
+        return plugins_url( '', self::plugin_path() . '/formidable.php' );
36 36
     }
37 37
 
38 38
 	public static function relative_plugin_url() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string
55 55
      */
56 56
     public static function site_name() {
57
-        return get_option('blogname');
57
+        return get_option( 'blogname' );
58 58
     }
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	public static function get_affiliate() {
69
-		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') );
69
+		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) );
70 70
 		$affiliate_id = strtolower( $affiliate_id );
71 71
 		$allowed_affiliates = array( 'mojo' );
72 72
 		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public static function get_settings() {
87 87
         global $frm_settings;
88
-        if ( empty($frm_settings) ) {
88
+        if ( empty( $frm_settings ) ) {
89 89
             $frm_settings = new FrmSettings();
90 90
         }
91 91
         return $frm_settings;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     }
102 102
 
103 103
     public static function pro_is_installed() {
104
-        return apply_filters('frm_pro_installed', false);
104
+        return apply_filters( 'frm_pro_installed', false );
105 105
     }
106 106
 
107 107
     /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      * @return boolean
146 146
      */
147 147
     public static function doing_ajax() {
148
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
148
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
149 149
     }
150 150
 
151 151
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @return boolean
166 166
      */
167 167
     public static function is_admin() {
168
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
168
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
169 169
     }
170 170
 
171 171
     /**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @return string
192 192
      */
193 193
 	public static function get_server_value( $value ) {
194
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
194
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
195 195
     }
196 196
 
197 197
     /**
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
207 207
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
208 208
         ) as $key ) {
209
-            if ( ! isset( $_SERVER[ $key ] ) ) {
209
+            if ( ! isset( $_SERVER[$key] ) ) {
210 210
                 continue;
211 211
             }
212 212
 
213
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
214
-                $ip = trim($ip); // just to be safe
213
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
214
+                $ip = trim( $ip ); // just to be safe
215 215
 
216
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
216
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
217 217
                     return $ip;
218 218
                 }
219 219
             }
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
     }
224 224
 
225 225
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
226
-        if ( strpos($param, '[') ) {
227
-            $params = explode('[', $param);
226
+        if ( strpos( $param, '[' ) ) {
227
+            $params = explode( '[', $param );
228 228
             $param = $params[0];
229 229
         }
230 230
 
231 231
 		if ( $src == 'get' ) {
232
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
233
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
234
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
232
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
233
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
234
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
235 235
             }
236 236
 			self::sanitize_value( $sanitize, $value );
237 237
 		} else {
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
 
241 241
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
242 242
             foreach ( $params as $k => $p ) {
243
-                if ( ! $k || ! is_array($value) ) {
243
+                if ( ! $k || ! is_array( $value ) ) {
244 244
                     continue;
245 245
                 }
246 246
 
247
-                $p = trim($p, ']');
248
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
247
+                $p = trim( $p, ']' );
248
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
249 249
             }
250 250
         }
251 251
 
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 
288 288
 		$value = $args['default'];
289 289
 		if ( $args['type'] == 'get' ) {
290
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
291
-				$value = $_GET[ $args['param'] ];
290
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
291
+				$value = $_GET[$args['param']];
292 292
 			}
293 293
 		} else if ( $args['type'] == 'post' ) {
294
-			if ( isset( $_POST[ $args['param'] ] ) ) {
295
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
294
+			if ( isset( $_POST[$args['param']] ) ) {
295
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
296 296
 			}
297 297
 		} else {
298
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
299
-				$value = $_REQUEST[ $args['param'] ];
298
+			if ( isset( $_REQUEST[$args['param']] ) ) {
299
+				$value = $_REQUEST[$args['param']];
300 300
 			}
301 301
 		}
302 302
 
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
     public static function sanitize_request( $sanitize_method, &$values ) {
333 333
         $temp_values = $values;
334 334
         foreach ( $temp_values as $k => $val ) {
335
-            if ( isset( $sanitize_method[ $k ] ) ) {
336
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
335
+            if ( isset( $sanitize_method[$k] ) ) {
336
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
337 337
             }
338 338
         }
339 339
     }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	public static function sanitize_array( &$values ) {
342 342
 		$temp_values = $values;
343 343
 		foreach ( $temp_values as $k => $val ) {
344
-			$values[ $k ] = wp_kses_post( $val );
344
+			$values[$k] = wp_kses_post( $val );
345 345
 		}
346 346
 	}
347 347
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
 		$allowed_html = array();
363 363
 		foreach ( $allowed as $a ) {
364
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
364
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
365 365
 		}
366 366
 
367 367
 		return wp_kses( $value, $allowed_html );
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
      * @since 2.0
373 373
      */
374 374
     public static function remove_get_action() {
375
-        if ( ! isset($_GET) ) {
375
+        if ( ! isset( $_GET ) ) {
376 376
             return;
377 377
         }
378 378
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
         }
395 395
 
396 396
         global $wp_query;
397
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
398
-            $value = $wp_query->query_vars[ $param ];
397
+        if ( isset( $wp_query->query_vars[$param] ) ) {
398
+            $value = $wp_query->query_vars[$param];
399 399
         }
400 400
 
401 401
         return $value;
@@ -406,9 +406,9 @@  discard block
 block discarded – undo
406 406
      */
407 407
     public static function trigger_hook_load( $type, $object = null ) {
408 408
         // only load the form hooks once
409
-        $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
409
+        $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
410 410
         if ( ! $hooks_loaded ) {
411
-            do_action('frm_load_'. $type .'_hooks');
411
+            do_action( 'frm_load_' . $type . '_hooks' );
412 412
         }
413 413
     }
414 414
 
@@ -424,16 +424,16 @@  discard block
 block discarded – undo
424 424
      * @return mixed $results The cache or query results
425 425
      */
426 426
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
427
-        $results = wp_cache_get($cache_key, $group);
428
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
427
+        $results = wp_cache_get( $cache_key, $group );
428
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
429 429
             return $results;
430 430
         }
431 431
 
432 432
         if ( 'get_posts' == $type ) {
433
-            $results = get_posts($query);
433
+            $results = get_posts( $query );
434 434
         } else {
435 435
             global $wpdb;
436
-            $results = $wpdb->{$type}($query);
436
+            $results = $wpdb->{$type}( $query );
437 437
         }
438 438
 
439 439
 		if ( ! self::prevent_caching() ) {
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
         }
458 458
 
459 459
         // then check the transient
460
-        $results = get_transient($cache_key);
460
+        $results = get_transient( $cache_key );
461 461
         if ( $results ) {
462
-            wp_cache_set($cache_key, $results);
462
+            wp_cache_set( $cache_key, $results );
463 463
         }
464 464
 
465 465
         return $results;
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
      * @param string $cache_key
471 471
      */
472 472
 	public static function delete_cache_and_transient( $cache_key ) {
473
-        delete_transient($cache_key);
474
-        wp_cache_delete($cache_key);
473
+        delete_transient( $cache_key );
474
+        wp_cache_delete( $cache_key );
475 475
     }
476 476
 
477 477
     /**
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 	public static function cache_delete_group( $group ) {
486 486
     	global $wp_object_cache;
487 487
 
488
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
489
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
490
-                wp_cache_delete($k, $group);
488
+        if ( isset( $wp_object_cache->cache[$group] ) ) {
489
+            foreach ( $wp_object_cache->cache[$group] as $k => $v ) {
490
+                wp_cache_delete( $k, $group );
491 491
             }
492 492
             return true;
493 493
         }
@@ -518,29 +518,29 @@  discard block
 block discarded – undo
518 518
 	public static function load_scripts( $scripts ) {
519 519
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
520 520
         foreach ( (array) $scripts as $s ) {
521
-            wp_enqueue_script($s);
521
+            wp_enqueue_script( $s );
522 522
         }
523 523
     }
524 524
 
525 525
 	public static function load_styles( $styles ) {
526 526
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
527 527
         foreach ( (array) $styles as $s ) {
528
-            wp_enqueue_style($s);
528
+            wp_enqueue_style( $s );
529 529
         }
530 530
     }
531 531
 
532 532
     public static function get_pages() {
533
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
533
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
534 534
     }
535 535
 
536 536
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
537 537
         $pages = self::get_pages();
538 538
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
539 539
     ?>
540
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
540
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
541 541
             <option value=""> </option>
542 542
             <?php foreach ( $pages as $page ) { ?>
543
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
543
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
544 544
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
545 545
 				</option>
546 546
             <?php } ?>
@@ -549,26 +549,26 @@  discard block
 block discarded – undo
549 549
     }
550 550
 
551 551
 	public static function post_edit_link( $post_id ) {
552
-        $post = get_post($post_id);
552
+        $post = get_post( $post_id );
553 553
         if ( $post ) {
554
-			return '<a href="'. esc_url( admin_url('post.php?post='. $post_id .'&action=edit') ) .'">'. self::truncate( $post->post_title, 50 ) .'</a>';
554
+			return '<a href="' . esc_url( admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
555 555
         }
556 556
         return '';
557 557
     }
558 558
 
559 559
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
560 560
     ?>
561
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
561
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
562 562
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
563 563
             ?> class="frm_multiselect">
564
-            <?php self::roles_options($capability); ?>
564
+            <?php self::roles_options( $capability ); ?>
565 565
         </select>
566 566
     <?php
567 567
     }
568 568
 
569 569
 	public static function roles_options( $capability ) {
570 570
         global $frm_vars;
571
-        if ( isset($frm_vars['editable_roles']) ) {
571
+        if ( isset( $frm_vars['editable_roles'] ) ) {
572 572
             $editable_roles = $frm_vars['editable_roles'];
573 573
         } else {
574 574
             $editable_roles = get_editable_roles();
@@ -576,10 +576,10 @@  discard block
 block discarded – undo
576 576
         }
577 577
 
578 578
         foreach ( $editable_roles as $role => $details ) {
579
-            $name = translate_user_role($details['name'] ); ?>
580
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
579
+            $name = translate_user_role( $details['name'] ); ?>
580
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
581 581
 <?php
582
-            unset($role, $details);
582
+            unset( $role, $details );
583 583
         }
584 584
     }
585 585
 
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
     public static function maybe_add_permissions() {
636 636
 		self::force_capability( 'frm_view_entries' );
637 637
 
638
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
638
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
639 639
             return;
640 640
         }
641 641
 
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
         $frm_roles = self::frm_capabilities();
645 645
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
646 646
 			$user->add_cap( $frm_role );
647
-            unset($frm_role, $frm_role_description);
647
+            unset( $frm_role, $frm_role_description );
648 648
         }
649 649
     }
650 650
 
@@ -669,12 +669,12 @@  discard block
 block discarded – undo
669 669
      * @param string $permission
670 670
      */
671 671
 	public static function permission_check( $permission, $show_message = 'show' ) {
672
-        $permission_error = self::permission_nonce_error($permission);
672
+        $permission_error = self::permission_nonce_error( $permission );
673 673
         if ( $permission_error !== false ) {
674 674
             if ( 'hide' == $show_message ) {
675 675
                 $permission_error = '';
676 676
             }
677
-            wp_die($permission_error);
677
+            wp_die( $permission_error );
678 678
         }
679 679
     }
680 680
 
@@ -691,11 +691,11 @@  discard block
 block discarded – undo
691 691
 		}
692 692
 
693 693
 		$error = false;
694
-        if ( empty($nonce_name) ) {
694
+        if ( empty( $nonce_name ) ) {
695 695
             return $error;
696 696
         }
697 697
 
698
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
698
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
699 699
             $frm_settings = self::get_settings();
700 700
             $error = $frm_settings->admin_permission;
701 701
         }
@@ -711,9 +711,9 @@  discard block
 block discarded – undo
711 711
 
712 712
 	public static function check_selected( $values, $current ) {
713 713
         $values = self::recursive_function_map( $values, 'trim' );
714
-        $current = trim($current);
714
+        $current = trim( $current );
715 715
 
716
-        return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
716
+        return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
717 717
     }
718 718
 
719 719
     /**
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 			} else {
775 775
 				foreach ( $value as $k => $v ) {
776 776
 					if ( ! is_array( $v ) ) {
777
-						$value[ $k ] = call_user_func( $original_function, $v );
777
+						$value[$k] = call_user_func( $original_function, $v );
778 778
 					}
779 779
 				}
780 780
 			}
@@ -795,11 +795,11 @@  discard block
 block discarded – undo
795 795
 	public static function array_flatten( $array, $keys = 'keep' ) {
796 796
         $return = array();
797 797
         foreach ( $array as $key => $value ) {
798
-            if ( is_array($value) ) {
798
+            if ( is_array( $value ) ) {
799 799
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
800 800
             } else {
801 801
 				if ( $keys == 'keep' ) {
802
-					$return[ $key ] = $value;
802
+					$return[$key] = $value;
803 803
 				} else {
804 804
 					$return[] = $value;
805 805
 				}
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
     }
810 810
 
811 811
     public static function esc_textarea( $text ) {
812
-        $safe_text = str_replace('&quot;', '"', $text);
812
+        $safe_text = str_replace( '&quot;', '"', $text );
813 813
         $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
814 814
     	return apply_filters( 'esc_textarea', $safe_text, $text );
815 815
     }
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
      * @since 2.0
820 820
      */
821 821
 	public static function use_wpautop( $content ) {
822
-        if ( apply_filters('frm_use_wpautop', true) ) {
823
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
822
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
823
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
824 824
         }
825 825
         return $content;
826 826
     }
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
      * @return string The base Google APIS url for the current version of jQuery UI
839 839
      */
840 840
     public static function jquery_ui_base_url() {
841
-        $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
842
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
841
+        $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
842
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
843 843
         return $url;
844 844
     }
845 845
 
@@ -854,11 +854,11 @@  discard block
 block discarded – undo
854 854
 
855 855
         $ver = 0;
856 856
 
857
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
857
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
858 858
             return $ver;
859 859
         }
860 860
 
861
-        $query = $wp_scripts->registered[ $handle ];
861
+        $query = $wp_scripts->registered[$handle];
862 862
     	if ( is_object( $query ) ) {
863 863
     	    $ver = $query->ver;
864 864
     	}
@@ -871,36 +871,36 @@  discard block
 block discarded – undo
871 871
     }
872 872
 
873 873
 	public static function get_user_id_param( $user_id ) {
874
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
874
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
875 875
             return $user_id;
876 876
         }
877 877
 
878 878
 		if ( $user_id == 'current' ) {
879 879
 			$user_id = get_current_user_id();
880 880
 		} else {
881
-            if ( is_email($user_id) ) {
882
-                $user = get_user_by('email', $user_id);
881
+            if ( is_email( $user_id ) ) {
882
+                $user = get_user_by( 'email', $user_id );
883 883
             } else {
884
-                $user = get_user_by('login', $user_id);
884
+                $user = get_user_by( 'login', $user_id );
885 885
             }
886 886
 
887 887
             if ( $user ) {
888 888
                 $user_id = $user->ID;
889 889
             }
890
-            unset($user);
890
+            unset( $user );
891 891
         }
892 892
 
893 893
         return $user_id;
894 894
     }
895 895
 
896 896
 	public static function get_file_contents( $filename, $atts = array() ) {
897
-        if ( ! is_file($filename) ) {
897
+        if ( ! is_file( $filename ) ) {
898 898
             return false;
899 899
         }
900 900
 
901
-        extract($atts);
901
+        extract( $atts );
902 902
         ob_start();
903
-        include($filename);
903
+        include( $filename );
904 904
         $contents = ob_get_contents();
905 905
         ob_end_clean();
906 906
         return $contents;
@@ -914,28 +914,28 @@  discard block
 block discarded – undo
914 914
         $key = '';
915 915
 
916 916
         if ( ! empty( $name ) ) {
917
-            $key = sanitize_key($name);
917
+            $key = sanitize_key( $name );
918 918
         }
919 919
 
920 920
 		if ( empty( $key ) ) {
921
-            $max_slug_value = pow(36, $num_chars);
921
+            $max_slug_value = pow( 36, $num_chars );
922 922
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
923
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
923
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
924 924
         }
925 925
 
926
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
927
-            $key = $key .'a';
926
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
927
+            $key = $key . 'a';
928 928
         }
929 929
 
930 930
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
931 931
 
932
-        if ( $key_check || is_numeric($key_check) ) {
932
+        if ( $key_check || is_numeric( $key_check ) ) {
933 933
             $suffix = 2;
934 934
 			do {
935 935
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
936 936
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
937
-				$suffix++;
938
-			} while ($key_check || is_numeric($key_check));
937
+				$suffix ++;
938
+			} while ( $key_check || is_numeric( $key_check ) );
939 939
 			$key = $alt_post_name;
940 940
         }
941 941
         return $key;
@@ -953,32 +953,32 @@  discard block
 block discarded – undo
953 953
 
954 954
         global $frm_vars;
955 955
 
956
-        if ( empty($post_values) ) {
957
-            $post_values = stripslashes_deep($_POST);
956
+        if ( empty( $post_values ) ) {
957
+            $post_values = stripslashes_deep( $_POST );
958 958
         }
959 959
 
960 960
 		$values = array( 'id' => $record->id, 'fields' => array() );
961 961
 
962 962
 		foreach ( array( 'name', 'description' ) as $var ) {
963
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
964
-            $values[ $var ] = self::get_param( $var, $default_val );
965
-            unset($var, $default_val);
963
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
964
+            $values[$var] = self::get_param( $var, $default_val );
965
+            unset( $var, $default_val );
966 966
         }
967 967
 
968
-        $values['description'] = self::use_wpautop($values['description']);
968
+        $values['description'] = self::use_wpautop( $values['description'] );
969 969
         $frm_settings = self::get_settings();
970
-        $is_form_builder = self::is_admin_page('formidable' );
970
+        $is_form_builder = self::is_admin_page( 'formidable' );
971 971
 
972 972
         foreach ( (array) $fields as $field ) {
973 973
             // Make sure to filter default values (for placeholder text), but not on the form builder page
974 974
             if ( ! $is_form_builder ) {
975
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
975
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
976 976
             }
977 977
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
978
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
978
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
979 979
         }
980 980
 
981
-        self::fill_form_opts($record, $table, $post_values, $values);
981
+        self::fill_form_opts( $record, $table, $post_values, $values );
982 982
 
983 983
         if ( $table == 'entries' ) {
984 984
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
         if ( $args['default'] ) {
996 996
             $meta_value = $field->default_value;
997 997
         } else {
998
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
999
-                if ( ! isset($field->field_options['custom_field']) ) {
998
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
999
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1000 1000
                     $field->field_options['custom_field'] = '';
1001 1001
                 }
1002 1002
 				$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 ) );
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
             }
1006 1006
         }
1007 1007
 
1008
-        $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
1009
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1008
+        $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1009
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1010 1010
 
1011 1011
         $field_array = array(
1012 1012
             'id'            => $field->id,
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
             'default_value' => $field->default_value,
1015 1015
             'name'          => $field->name,
1016 1016
             'description'   => $field->description,
1017
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1017
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1018 1018
             'options'       => $field->options,
1019 1019
             'required'      => $field->required,
1020 1020
             'field_key'     => $field->field_key,
@@ -1024,38 +1024,38 @@  discard block
 block discarded – undo
1024 1024
         );
1025 1025
 
1026 1026
         $args['field_type'] = $field_type;
1027
-        self::fill_field_opts($field, $field_array, $args);
1027
+        self::fill_field_opts( $field, $field_array, $args );
1028 1028
 
1029
-        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1029
+        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] );
1030 1030
 
1031
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1031
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1032 1032
             $field_array['unique_msg'] = '';
1033 1033
         }
1034 1034
 
1035 1035
         $field_array = array_merge( $field->field_options, $field_array );
1036 1036
 
1037
-        $values['fields'][ $field->id ] = $field_array;
1037
+        $values['fields'][$field->id] = $field_array;
1038 1038
     }
1039 1039
 
1040 1040
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1041 1041
         $post_values = $args['post_values'];
1042
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1042
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1043 1043
 
1044 1044
         foreach ( $opt_defaults as $opt => $default_opt ) {
1045
-            $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 );
1046
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1047
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1048
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1045
+            $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 );
1046
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1047
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1048
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1049 1049
                 if ( $args['field_type'] == 'captcha' ) {
1050
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1050
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1051 1051
                 } else {
1052
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1052
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1053 1053
                 }
1054 1054
             }
1055 1055
         }
1056 1056
 
1057 1057
         if ( $field_array['custom_html'] == '' ) {
1058
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1058
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1059 1059
         }
1060 1060
     }
1061 1061
 
@@ -1074,18 +1074,18 @@  discard block
 block discarded – undo
1074 1074
             return;
1075 1075
         }
1076 1076
 
1077
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1077
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1078 1078
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1079 1079
 
1080
-        if ( ! is_array($form->options) ) {
1080
+        if ( ! is_array( $form->options ) ) {
1081 1081
             return;
1082 1082
         }
1083 1083
 
1084 1084
         foreach ( $form->options as $opt => $value ) {
1085
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1085
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1086 1086
         }
1087 1087
 
1088
-        self::fill_form_defaults($post_values, $values);
1088
+        self::fill_form_defaults( $post_values, $values );
1089 1089
     }
1090 1090
 
1091 1091
     /**
@@ -1095,23 +1095,23 @@  discard block
 block discarded – undo
1095 1095
         $form_defaults = FrmFormsHelper::get_default_opts();
1096 1096
 
1097 1097
         foreach ( $form_defaults as $opt => $default ) {
1098
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1099
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1098
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1099
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1100 1100
             }
1101 1101
 
1102
-            unset($opt, $defaut);
1102
+            unset( $opt, $defaut );
1103 1103
         }
1104 1104
 
1105
-        if ( ! isset($values['custom_style']) ) {
1105
+        if ( ! isset( $values['custom_style'] ) ) {
1106 1106
             $frm_settings = self::get_settings();
1107 1107
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1108 1108
         }
1109 1109
 
1110 1110
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1111
-            if ( ! isset( $values[ $h .'_html' ] ) ) {
1112
-                $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1111
+            if ( ! isset( $values[$h . '_html'] ) ) {
1112
+                $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1113 1113
             }
1114
-            unset($h);
1114
+            unset( $h );
1115 1115
         }
1116 1116
     }
1117 1117
 
@@ -1127,9 +1127,9 @@  discard block
 block discarded – undo
1127 1127
         }
1128 1128
     ?>
1129 1129
 <li>
1130
-    <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>
1131
-    <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>
1132
-    <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>
1130
+    <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>
1131
+    <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>
1132
+    <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>
1133 1133
 </li>
1134 1134
     <?php
1135 1135
     }
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
             return '';
1158 1158
         } else if ( $length <= 10 ) {
1159 1159
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1160
-            return $sub . (($length < $original_len) ? $continue : '');
1160
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1161 1161
         }
1162 1162
 
1163 1163
         $sub = '';
@@ -1166,23 +1166,23 @@  discard block
 block discarded – undo
1166 1166
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1167 1167
 
1168 1168
 		foreach ( $words as $word ) {
1169
-            $part = (($sub != '') ? ' ' : '') . $word;
1169
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1170 1170
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1171
-            if ( $total_len > $length && str_word_count($sub) ) {
1171
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1172 1172
                 break;
1173 1173
             }
1174 1174
 
1175 1175
             $sub .= $part;
1176 1176
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1177 1177
 
1178
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1178
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1179 1179
                 break;
1180 1180
             }
1181 1181
 
1182
-            unset($total_len, $word);
1182
+            unset( $total_len, $word );
1183 1183
         }
1184 1184
 
1185
-        return $sub . (($len < $original_len) ? $continue : '');
1185
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1186 1186
     }
1187 1187
 
1188 1188
 	public static function mb_function( $function_names, $args ) {
@@ -1195,17 +1195,17 @@  discard block
 block discarded – undo
1195 1195
 	}
1196 1196
 
1197 1197
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1198
-        if ( empty($date) ) {
1198
+        if ( empty( $date ) ) {
1199 1199
             return $date;
1200 1200
         }
1201 1201
 
1202
-        if ( empty($date_format) ) {
1203
-            $date_format = get_option('date_format');
1202
+        if ( empty( $date_format ) ) {
1203
+            $date_format = get_option( 'date_format' );
1204 1204
         }
1205 1205
 
1206
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1206
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1207 1207
             $frmpro_settings = new FrmProSettings();
1208
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1208
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1209 1209
         }
1210 1210
 
1211 1211
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 
1221 1221
 	private static function add_time_to_date( $time_format, $date ) {
1222 1222
 		if ( empty( $time_format ) ) {
1223
-			$time_format = get_option('time_format');
1223
+			$time_format = get_option( 'time_format' );
1224 1224
 		}
1225 1225
 
1226 1226
 		$trimmed_format = trim( $time_format );
@@ -1266,10 +1266,10 @@  discard block
 block discarded – undo
1266 1266
 		$time_strings = self::get_time_strings();
1267 1267
 
1268 1268
 		foreach ( $time_strings as $k => $v ) {
1269
-			if ( $diff[ $k ] ) {
1270
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1269
+			if ( $diff[$k] ) {
1270
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1271 1271
 			} else {
1272
-				unset( $time_strings[ $k ] );
1272
+				unset( $time_strings[$k] );
1273 1273
 			}
1274 1274
 		}
1275 1275
 
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
      */
1308 1308
 	public static function esc_like( $term ) {
1309 1309
         global $wpdb;
1310
-        if ( method_exists($wpdb, 'esc_like') ) {
1310
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1311 1311
 			// WP 4.0
1312 1312
             $term = $wpdb->esc_like( $term );
1313 1313
         } else {
@@ -1321,17 +1321,17 @@  discard block
 block discarded – undo
1321 1321
      * @param string $order_query
1322 1322
      */
1323 1323
 	public static function esc_order( $order_query ) {
1324
-        if ( empty($order_query) ) {
1324
+        if ( empty( $order_query ) ) {
1325 1325
             return '';
1326 1326
         }
1327 1327
 
1328 1328
         // remove ORDER BY before santizing
1329
-        $order_query = strtolower($order_query);
1330
-        if ( strpos($order_query, 'order by') !== false ) {
1331
-            $order_query = str_replace('order by', '', $order_query);
1329
+        $order_query = strtolower( $order_query );
1330
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1331
+            $order_query = str_replace( 'order by', '', $order_query );
1332 1332
         }
1333 1333
 
1334
-        $order_query = explode(' ', trim($order_query));
1334
+        $order_query = explode( ' ', trim( $order_query ) );
1335 1335
 
1336 1336
         $order_fields = array(
1337 1337
             'id', 'form_key', 'name', 'description',
@@ -1339,18 +1339,18 @@  discard block
 block discarded – undo
1339 1339
             'default_template', 'status', 'created_at',
1340 1340
         );
1341 1341
 
1342
-        $order = trim(trim(reset($order_query), ','));
1343
-        if ( ! in_array($order, $order_fields) ) {
1342
+        $order = trim( trim( reset( $order_query ), ',' ) );
1343
+        if ( ! in_array( $order, $order_fields ) ) {
1344 1344
             return '';
1345 1345
         }
1346 1346
 
1347 1347
         $order_by = '';
1348
-        if ( count($order_query) > 1 ) {
1348
+        if ( count( $order_query ) > 1 ) {
1349 1349
 			$order_by = end( $order_query );
1350 1350
 			self::esc_order_by( $order_by );
1351 1351
         }
1352 1352
 
1353
-        return ' ORDER BY '. $order . ' '. $order_by;
1353
+        return ' ORDER BY ' . $order . ' ' . $order_by;
1354 1354
     }
1355 1355
 
1356 1356
 	/**
@@ -1367,24 +1367,24 @@  discard block
 block discarded – undo
1367 1367
      * @param string $limit
1368 1368
      */
1369 1369
 	public static function esc_limit( $limit ) {
1370
-        if ( empty($limit) ) {
1370
+        if ( empty( $limit ) ) {
1371 1371
             return '';
1372 1372
         }
1373 1373
 
1374
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1375
-        if ( is_numeric($limit) ) {
1376
-            return ' LIMIT '. $limit;
1374
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1375
+        if ( is_numeric( $limit ) ) {
1376
+            return ' LIMIT ' . $limit;
1377 1377
         }
1378 1378
 
1379
-        $limit = explode(',', trim($limit));
1379
+        $limit = explode( ',', trim( $limit ) );
1380 1380
         foreach ( $limit as $k => $l ) {
1381 1381
             if ( is_numeric( $l ) ) {
1382
-                $limit[ $k ] = $l;
1382
+                $limit[$k] = $l;
1383 1383
             }
1384 1384
         }
1385 1385
 
1386
-        $limit = implode(',', $limit);
1387
-        return ' LIMIT '. $limit;
1386
+        $limit = implode( ',', $limit );
1387
+        return ' LIMIT ' . $limit;
1388 1388
     }
1389 1389
 
1390 1390
     /**
@@ -1392,12 +1392,12 @@  discard block
 block discarded – undo
1392 1392
      * @since 2.0
1393 1393
      */
1394 1394
     public static function prepare_array_values( $array, $type = '%s' ) {
1395
-        $placeholders = array_fill(0, count($array), $type);
1396
-        return implode(', ', $placeholders);
1395
+        $placeholders = array_fill( 0, count( $array ), $type );
1396
+        return implode( ', ', $placeholders );
1397 1397
     }
1398 1398
 
1399 1399
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1400
-        if ( empty($where) ) {
1400
+        if ( empty( $where ) ) {
1401 1401
             return '';
1402 1402
         }
1403 1403
 
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 
1444 1444
     public static function get_referer_info() {
1445 1445
         _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1446
-        return self::get_server_value('HTTP_REFERER');
1446
+        return self::get_server_value( 'HTTP_REFERER' );
1447 1447
     }
1448 1448
 
1449 1449
 	/**
@@ -1452,19 +1452,19 @@  discard block
 block discarded – undo
1452 1452
 	public static function json_to_array( $json_vars ) {
1453 1453
         $vars = array();
1454 1454
         foreach ( $json_vars as $jv ) {
1455
-            $jv_name = explode('[', $jv['name']);
1456
-            $last = count($jv_name) - 1;
1455
+            $jv_name = explode( '[', $jv['name'] );
1456
+            $last = count( $jv_name ) - 1;
1457 1457
             foreach ( $jv_name as $p => $n ) {
1458
-                $name = trim($n, ']');
1459
-                if ( ! isset($l1) ) {
1458
+                $name = trim( $n, ']' );
1459
+                if ( ! isset( $l1 ) ) {
1460 1460
                     $l1 = $name;
1461 1461
                 }
1462 1462
 
1463
-                if ( ! isset($l2) ) {
1463
+                if ( ! isset( $l2 ) ) {
1464 1464
                     $l2 = $name;
1465 1465
                 }
1466 1466
 
1467
-                if ( ! isset($l3) ) {
1467
+                if ( ! isset( $l3 ) ) {
1468 1468
                     $l3 = $name;
1469 1469
                 }
1470 1470
 
@@ -1478,24 +1478,24 @@  discard block
 block discarded – undo
1478 1478
 
1479 1479
                     case 1:
1480 1480
                         $l2 = $name;
1481
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1481
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1482 1482
                     break;
1483 1483
 
1484 1484
                     case 2:
1485 1485
                         $l3 = $name;
1486
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1486
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1487 1487
                     break;
1488 1488
 
1489 1489
                     case 3:
1490 1490
                         $l4 = $name;
1491
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1491
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1492 1492
                     break;
1493 1493
                 }
1494 1494
 
1495
-                unset($this_val, $n);
1495
+                unset( $this_val, $n );
1496 1496
             }
1497 1497
 
1498
-            unset($last, $jv);
1498
+            unset( $last, $jv );
1499 1499
         }
1500 1500
 
1501 1501
         return $vars;
@@ -1508,8 +1508,8 @@  discard block
 block discarded – undo
1508 1508
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1509 1509
         if ( $name == '' ) {
1510 1510
             $vars[] = $val;
1511
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1512
-            $vars[ $l1 ] = $val;
1511
+        } else if ( ! isset( $vars[$l1] ) ) {
1512
+            $vars[$l1] = $val;
1513 1513
         }
1514 1514
     }
1515 1515
 
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
             '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() ) ),
1525 1525
         );
1526 1526
 
1527
-        if ( ! isset( $tooltips[ $name ] ) ) {
1527
+        if ( ! isset( $tooltips[$name] ) ) {
1528 1528
             return;
1529 1529
         }
1530 1530
 
@@ -1534,7 +1534,7 @@  discard block
 block discarded – undo
1534 1534
             echo ' class="frm_help"';
1535 1535
         }
1536 1536
 
1537
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1537
+        echo ' title="' . esc_attr( $tooltips[$name] );
1538 1538
 
1539 1539
         if ( 'open' != $class ) {
1540 1540
             echo '"';
@@ -1586,13 +1586,13 @@  discard block
 block discarded – undo
1586 1586
     }
1587 1587
 
1588 1588
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1589
-		if ( ! isset( $post_content[ $key ] ) ) {
1589
+		if ( ! isset( $post_content[$key] ) ) {
1590 1590
 			return;
1591 1591
 		}
1592 1592
 
1593 1593
 		if ( is_array( $val ) ) {
1594 1594
 			foreach ( $val as $k1 => $v1 ) {
1595
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1595
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1596 1596
 				unset( $k1, $v1 );
1597 1597
 			}
1598 1598
 		} else {
@@ -1600,7 +1600,7 @@  discard block
 block discarded – undo
1600 1600
 			$val = stripslashes( $val );
1601 1601
 
1602 1602
 			// Add backslashes before double quotes and forward slashes only
1603
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1603
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1604 1604
 		}
1605 1605
 	}
1606 1606
 
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1618 1618
 
1619 1619
 		if ( empty( $settings['ID'] ) ) {
1620
-			unset( $settings['ID']);
1620
+			unset( $settings['ID'] );
1621 1621
 		}
1622 1622
 
1623 1623
 		// delete all caches for this group
@@ -1651,17 +1651,17 @@  discard block
 block discarded – undo
1651 1651
 	}
1652 1652
 
1653 1653
 	public static function maybe_json_decode( $string ) {
1654
-        if ( is_array($string) ) {
1654
+        if ( is_array( $string ) ) {
1655 1655
             return $string;
1656 1656
         }
1657 1657
 
1658
-        $new_string = json_decode($string, true);
1659
-        if ( function_exists('json_last_error') ) {
1658
+        $new_string = json_decode( $string, true );
1659
+        if ( function_exists( 'json_last_error' ) ) {
1660 1660
 			// php 5.3+
1661 1661
             if ( json_last_error() == JSON_ERROR_NONE ) {
1662 1662
                 $string = $new_string;
1663 1663
             }
1664
-        } else if ( isset($new_string) ) {
1664
+        } else if ( isset( $new_string ) ) {
1665 1665
 			// php < 5.3 fallback
1666 1666
             $string = $new_string;
1667 1667
         }
@@ -1677,11 +1677,11 @@  discard block
 block discarded – undo
1677 1677
 	public static function maybe_highlight_menu( $post_type ) {
1678 1678
         global $post, $pagenow;
1679 1679
 
1680
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1680
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1681 1681
             return;
1682 1682
         }
1683 1683
 
1684
-        if ( is_object($post) && $post->post_type != $post_type ) {
1684
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1685 1685
             return;
1686 1686
         }
1687 1687
 
@@ -1779,11 +1779,11 @@  discard block
 block discarded – undo
1779 1779
         $frm_version = self::plugin_version();
1780 1780
 
1781 1781
         // check if Formidable meets minimum requirements
1782
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1782
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1783 1783
             return;
1784 1784
         }
1785 1785
 
1786
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1786
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1787 1787
 		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">' .
1788 1788
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1789 1789
         '</div></td></tr>';
@@ -1791,38 +1791,38 @@  discard block
 block discarded – undo
1791 1791
 
1792 1792
     public static function locales( $type = 'date' ) {
1793 1793
         $locales = array(
1794
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1795
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1796
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1794
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1795
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1796
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1797 1797
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1798
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1799
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1798
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1799
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1800 1800
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1801
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1802
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1801
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1802
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1803 1803
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1804
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1804
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1805 1805
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1806
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1806
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1807 1807
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1808
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1808
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1809 1809
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1810
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1811
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1812
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1813
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1814
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1810
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1811
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1812
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1813
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1814
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1815 1815
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1816
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1816
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1817 1817
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1818 1818
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1819
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1819
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1820 1820
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1821
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1821
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1822 1822
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1823
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1824
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1825
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1823
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1824
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1825
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1826 1826
         );
1827 1827
 
1828 1828
         if ( $type == 'captcha' ) {
@@ -1841,8 +1841,8 @@  discard block
 block discarded – undo
1841 1841
             );
1842 1842
         }
1843 1843
 
1844
-        $locales = array_diff_key($locales, array_flip($unset));
1845
-        $locales = apply_filters('frm_locales', $locales);
1844
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1845
+        $locales = apply_filters( 'frm_locales', $locales );
1846 1846
 
1847 1847
         return $locales;
1848 1848
     }
Please login to merge, or discard this patch.
Indentation   +1124 added lines, -1124 removed lines patch added patch discarded remove patch
@@ -12,50 +12,50 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.0.22b1';
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 make_affiliate_url( $url ) {
61 61
 		$affiliate_id = self::get_affiliate();
@@ -75,78 +75,78 @@  discard block
 block discarded – undo
75 75
 		return $affiliate_id;
76 76
 	}
77 77
 
78
-    /**
79
-     * Get the Formidable settings
80
-     *
81
-     * @since 2.0
82
-     *
83
-     * @param None
84
-     * @return FrmSettings $frm_setings
85
-     */
86
-    public static function get_settings() {
87
-        global $frm_settings;
88
-        if ( empty($frm_settings) ) {
89
-            $frm_settings = new FrmSettings();
90
-        }
91
-        return $frm_settings;
92
-    }
93
-
94
-    /**
95
-     * Show a message in place of pro features
96
-     *
97
-     * @since 2.0
98
-     */
78
+	/**
79
+	 * Get the Formidable settings
80
+	 *
81
+	 * @since 2.0
82
+	 *
83
+	 * @param None
84
+	 * @return FrmSettings $frm_setings
85
+	 */
86
+	public static function get_settings() {
87
+		global $frm_settings;
88
+		if ( empty($frm_settings) ) {
89
+			$frm_settings = new FrmSettings();
90
+		}
91
+		return $frm_settings;
92
+	}
93
+
94
+	/**
95
+	 * Show a message in place of pro features
96
+	 *
97
+	 * @since 2.0
98
+	 */
99 99
 	public static function update_message( $features, $class = '' ) {
100 100
 		_deprecated_function( __FUNCTION__, '2.0.19' );
101
-    }
102
-
103
-    public static function pro_is_installed() {
104
-        return apply_filters('frm_pro_installed', false);
105
-    }
106
-
107
-    /**
108
-     * Check for certain page in Formidable settings
109
-     *
110
-     * @since 2.0
111
-     *
112
-     * @param string $page The name of the page to check
113
-     * @return boolean
114
-     */
101
+	}
102
+
103
+	public static function pro_is_installed() {
104
+		return apply_filters('frm_pro_installed', false);
105
+	}
106
+
107
+	/**
108
+	 * Check for certain page in Formidable settings
109
+	 *
110
+	 * @since 2.0
111
+	 *
112
+	 * @param string $page The name of the page to check
113
+	 * @return boolean
114
+	 */
115 115
 	public static function is_admin_page( $page = 'formidable' ) {
116
-        global $pagenow;
116
+		global $pagenow;
117 117
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
118
-        if ( $pagenow ) {
118
+		if ( $pagenow ) {
119 119
 			return $pagenow == 'admin.php' && $get_page == $page;
120
-        }
120
+		}
121 121
 
122 122
 		return is_admin() && $get_page == $page;
123
-    }
124
-
125
-    /**
126
-     * Check for the form preview page
127
-     *
128
-     * @since 2.0
129
-     *
130
-     * @param None
131
-     * @return boolean
132
-     */
133
-    public static function is_preview_page() {
134
-        global $pagenow;
123
+	}
124
+
125
+	/**
126
+	 * Check for the form preview page
127
+	 *
128
+	 * @since 2.0
129
+	 *
130
+	 * @param None
131
+	 * @return boolean
132
+	 */
133
+	public static function is_preview_page() {
134
+		global $pagenow;
135 135
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
136 136
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
137
-    }
137
+	}
138 138
 
139
-    /**
140
-     * Check for ajax except the form preview page
141
-     *
142
-     * @since 2.0
143
-     *
144
-     * @param None
145
-     * @return boolean
146
-     */
147
-    public static function doing_ajax() {
148
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
149
-    }
139
+	/**
140
+	 * Check for ajax except the form preview page
141
+	 *
142
+	 * @since 2.0
143
+	 *
144
+	 * @param None
145
+	 * @return boolean
146
+	 */
147
+	public static function doing_ajax() {
148
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
149
+	}
150 150
 
151 151
 	/**
152 152
 	 * @since 2.0.8
@@ -156,101 +156,101 @@  discard block
 block discarded – undo
156 156
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
157 157
 	}
158 158
 
159
-    /**
160
-     * Check if on an admin page
161
-     *
162
-     * @since 2.0
163
-     *
164
-     * @param None
165
-     * @return boolean
166
-     */
167
-    public static function is_admin() {
168
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
169
-    }
170
-
171
-    /**
172
-     * Check if value contains blank value or empty array
173
-     *
174
-     * @since 2.0
175
-     * @param $value - value to check
176
-     * @return boolean
177
-     */
178
-    public static function is_empty_value( $value, $empty = '' ) {
179
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
180
-    }
181
-
182
-    public static function is_not_empty_value( $value, $empty = '' ) {
183
-        return ! self::is_empty_value( $value, $empty );
184
-    }
185
-
186
-    /**
187
-     * Get any value from the $_SERVER
188
-     *
189
-     * @since 2.0
190
-     * @param string $value
191
-     * @return string
192
-     */
159
+	/**
160
+	 * Check if on an admin page
161
+	 *
162
+	 * @since 2.0
163
+	 *
164
+	 * @param None
165
+	 * @return boolean
166
+	 */
167
+	public static function is_admin() {
168
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
169
+	}
170
+
171
+	/**
172
+	 * Check if value contains blank value or empty array
173
+	 *
174
+	 * @since 2.0
175
+	 * @param $value - value to check
176
+	 * @return boolean
177
+	 */
178
+	public static function is_empty_value( $value, $empty = '' ) {
179
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
180
+	}
181
+
182
+	public static function is_not_empty_value( $value, $empty = '' ) {
183
+		return ! self::is_empty_value( $value, $empty );
184
+	}
185
+
186
+	/**
187
+	 * Get any value from the $_SERVER
188
+	 *
189
+	 * @since 2.0
190
+	 * @param string $value
191
+	 * @return string
192
+	 */
193 193
 	public static function get_server_value( $value ) {
194
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
195
-    }
196
-
197
-    /**
198
-     * Check for the IP address in several places
199
-     * Used by [ip] shortcode
200
-     *
201
-     * @return string The IP address of the current user
202
-     */
203
-    public static function get_ip_address() {
194
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
195
+	}
196
+
197
+	/**
198
+	 * Check for the IP address in several places
199
+	 * Used by [ip] shortcode
200
+	 *
201
+	 * @return string The IP address of the current user
202
+	 */
203
+	public static function get_ip_address() {
204 204
 		$ip = '';
205
-        foreach ( array(
206
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
207
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
208
-        ) as $key ) {
209
-            if ( ! isset( $_SERVER[ $key ] ) ) {
210
-                continue;
211
-            }
212
-
213
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
214
-                $ip = trim($ip); // just to be safe
215
-
216
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
217
-                    return $ip;
218
-                }
219
-            }
220
-        }
205
+		foreach ( array(
206
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
207
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
208
+		) as $key ) {
209
+			if ( ! isset( $_SERVER[ $key ] ) ) {
210
+				continue;
211
+			}
212
+
213
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
214
+				$ip = trim($ip); // just to be safe
215
+
216
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
217
+					return $ip;
218
+				}
219
+			}
220
+		}
221 221
 
222 222
 		return sanitize_text_field( $ip );
223
-    }
223
+	}
224 224
 
225
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
226
-        if ( strpos($param, '[') ) {
227
-            $params = explode('[', $param);
228
-            $param = $params[0];
229
-        }
225
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
226
+		if ( strpos($param, '[') ) {
227
+			$params = explode('[', $param);
228
+			$param = $params[0];
229
+		}
230 230
 
231 231
 		if ( $src == 'get' ) {
232
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
233
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
234
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
235
-            }
232
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
233
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
234
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
235
+			}
236 236
 			self::sanitize_value( $sanitize, $value );
237 237
 		} else {
238
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
239
-        }
238
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
239
+		}
240 240
 
241 241
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
242
-            foreach ( $params as $k => $p ) {
243
-                if ( ! $k || ! is_array($value) ) {
244
-                    continue;
245
-                }
242
+			foreach ( $params as $k => $p ) {
243
+				if ( ! $k || ! is_array($value) ) {
244
+					continue;
245
+				}
246 246
 
247
-                $p = trim($p, ']');
248
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
249
-            }
250
-        }
247
+				$p = trim($p, ']');
248
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
249
+			}
250
+		}
251 251
 
252
-        return $value;
253
-    }
252
+		return $value;
253
+	}
254 254
 
255 255
 	/**
256 256
 	 *
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
273 273
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
274
-    }
274
+	}
275 275
 
276 276
 	/**
277 277
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 
307 307
 	/**
308
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
309
-	*
310
-	* @since 2.0.8
311
-	* @param string $value
312
-	* @return string $value
313
-	*/
308
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
309
+	 *
310
+	 * @since 2.0.8
311
+	 * @param string $value
312
+	 * @return string $value
313
+	 */
314 314
 	public static function preserve_backslashes( $value ) {
315 315
 		// If backslashes have already been added, don't add them again
316 316
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 	}
331 331
 
332
-    public static function sanitize_request( $sanitize_method, &$values ) {
333
-        $temp_values = $values;
334
-        foreach ( $temp_values as $k => $val ) {
335
-            if ( isset( $sanitize_method[ $k ] ) ) {
332
+	public static function sanitize_request( $sanitize_method, &$values ) {
333
+		$temp_values = $values;
334
+		foreach ( $temp_values as $k => $val ) {
335
+			if ( isset( $sanitize_method[ $k ] ) ) {
336 336
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
337
-            }
338
-        }
339
-    }
337
+			}
338
+		}
339
+	}
340 340
 
341 341
 	public static function sanitize_array( &$values ) {
342 342
 		$temp_values = $values;
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	public static function kses( $value, $allowed = array() ) {
353 353
 		$html = array(
354
-		    'a' => array(
354
+			'a' => array(
355 355
 				'href'  => array(),
356 356
 				'title' => array(),
357 357
 				'id'    => array(),
358 358
 				'class' => array(),
359
-		    ),
359
+			),
360 360
 		);
361 361
 
362 362
 		$allowed_html = array();
@@ -367,176 +367,176 @@  discard block
 block discarded – undo
367 367
 		return wp_kses( $value, $allowed_html );
368 368
 	}
369 369
 
370
-    /**
371
-     * Used when switching the action for a bulk action
372
-     * @since 2.0
373
-     */
374
-    public static function remove_get_action() {
375
-        if ( ! isset($_GET) ) {
376
-            return;
377
-        }
370
+	/**
371
+	 * Used when switching the action for a bulk action
372
+	 * @since 2.0
373
+	 */
374
+	public static function remove_get_action() {
375
+		if ( ! isset($_GET) ) {
376
+			return;
377
+		}
378 378
 
379
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
380
-        if ( ! empty( $new_action ) ) {
379
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
380
+		if ( ! empty( $new_action ) ) {
381 381
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
382
-        }
383
-    }
384
-
385
-    /**
386
-     * Check the WP query for a parameter
387
-     *
388
-     * @since 2.0
389
-     * @return string|array
390
-     */
391
-    public static function get_query_var( $value, $param ) {
392
-        if ( $value != '' ) {
393
-            return $value;
394
-        }
395
-
396
-        global $wp_query;
397
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
398
-            $value = $wp_query->query_vars[ $param ];
399
-        }
400
-
401
-        return $value;
402
-    }
403
-
404
-    /**
405
-     * @param string $type
406
-     */
407
-    public static function trigger_hook_load( $type, $object = null ) {
408
-        // only load the form hooks once
409
-        $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
410
-        if ( ! $hooks_loaded ) {
411
-            do_action('frm_load_'. $type .'_hooks');
412
-        }
413
-    }
414
-
415
-    /**
416
-     * Check cache before fetching values and saving to cache
417
-     *
418
-     * @since 2.0
419
-     *
420
-     * @param string $cache_key The unique name for this cache
421
-     * @param string $group The name of the cache group
422
-     * @param string $query If blank, don't run a db call
423
-     * @param string $type The wpdb function to use with this query
424
-     * @return mixed $results The cache or query results
425
-     */
426
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
427
-        $results = wp_cache_get($cache_key, $group);
428
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
429
-            return $results;
430
-        }
431
-
432
-        if ( 'get_posts' == $type ) {
433
-            $results = get_posts($query);
434
-        } else {
435
-            global $wpdb;
436
-            $results = $wpdb->{$type}($query);
437
-        }
382
+		}
383
+	}
384
+
385
+	/**
386
+	 * Check the WP query for a parameter
387
+	 *
388
+	 * @since 2.0
389
+	 * @return string|array
390
+	 */
391
+	public static function get_query_var( $value, $param ) {
392
+		if ( $value != '' ) {
393
+			return $value;
394
+		}
395
+
396
+		global $wp_query;
397
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
398
+			$value = $wp_query->query_vars[ $param ];
399
+		}
400
+
401
+		return $value;
402
+	}
403
+
404
+	/**
405
+	 * @param string $type
406
+	 */
407
+	public static function trigger_hook_load( $type, $object = null ) {
408
+		// only load the form hooks once
409
+		$hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
410
+		if ( ! $hooks_loaded ) {
411
+			do_action('frm_load_'. $type .'_hooks');
412
+		}
413
+	}
414
+
415
+	/**
416
+	 * Check cache before fetching values and saving to cache
417
+	 *
418
+	 * @since 2.0
419
+	 *
420
+	 * @param string $cache_key The unique name for this cache
421
+	 * @param string $group The name of the cache group
422
+	 * @param string $query If blank, don't run a db call
423
+	 * @param string $type The wpdb function to use with this query
424
+	 * @return mixed $results The cache or query results
425
+	 */
426
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
427
+		$results = wp_cache_get($cache_key, $group);
428
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
429
+			return $results;
430
+		}
431
+
432
+		if ( 'get_posts' == $type ) {
433
+			$results = get_posts($query);
434
+		} else {
435
+			global $wpdb;
436
+			$results = $wpdb->{$type}($query);
437
+		}
438 438
 
439 439
 		if ( ! self::prevent_caching() ) {
440 440
 			wp_cache_set( $cache_key, $results, $group, $time );
441 441
 		}
442 442
 
443
-        return $results;
444
-    }
443
+		return $results;
444
+	}
445 445
 
446
-    /**
447
-     * Data that should be stored for a long time can be stored in a transient.
448
-     * First check the cache, then check the transient
449
-     * @since 2.0
450
-     * @return mixed The cached value or false
451
-     */
446
+	/**
447
+	 * Data that should be stored for a long time can be stored in a transient.
448
+	 * First check the cache, then check the transient
449
+	 * @since 2.0
450
+	 * @return mixed The cached value or false
451
+	 */
452 452
 	public static function check_cache_and_transient( $cache_key ) {
453
-        // check caching layer first
454
-        $results = self::check_cache( $cache_key );
455
-        if ( $results ) {
456
-            return $results;
457
-        }
458
-
459
-        // then check the transient
460
-        $results = get_transient($cache_key);
461
-        if ( $results ) {
462
-            wp_cache_set($cache_key, $results);
463
-        }
464
-
465
-        return $results;
466
-    }
467
-
468
-    /**
469
-     * @since 2.0
470
-     * @param string $cache_key
471
-     */
453
+		// check caching layer first
454
+		$results = self::check_cache( $cache_key );
455
+		if ( $results ) {
456
+			return $results;
457
+		}
458
+
459
+		// then check the transient
460
+		$results = get_transient($cache_key);
461
+		if ( $results ) {
462
+			wp_cache_set($cache_key, $results);
463
+		}
464
+
465
+		return $results;
466
+	}
467
+
468
+	/**
469
+	 * @since 2.0
470
+	 * @param string $cache_key
471
+	 */
472 472
 	public static function delete_cache_and_transient( $cache_key ) {
473
-        delete_transient($cache_key);
474
-        wp_cache_delete($cache_key);
475
-    }
476
-
477
-    /**
478
-     * Delete all caching in a single group
479
-     *
480
-     * @since 2.0
481
-     *
482
-     * @param string $group The name of the cache group
483
-     * @return boolean True or False
484
-     */
473
+		delete_transient($cache_key);
474
+		wp_cache_delete($cache_key);
475
+	}
476
+
477
+	/**
478
+	 * Delete all caching in a single group
479
+	 *
480
+	 * @since 2.0
481
+	 *
482
+	 * @param string $group The name of the cache group
483
+	 * @return boolean True or False
484
+	 */
485 485
 	public static function cache_delete_group( $group ) {
486
-    	global $wp_object_cache;
487
-
488
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
489
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
490
-                wp_cache_delete($k, $group);
491
-            }
492
-            return true;
493
-        }
494
-
495
-    	return false;
496
-    }
497
-
498
-    /**
499
-     * Check a value from a shortcode to see if true or false.
500
-     * True when value is 1, true, 'true', 'yes'
501
-     *
502
-     * @since 1.07.10
503
-     *
504
-     * @param string $value The value to compare
505
-     * @return boolean True or False
506
-     */
486
+		global $wp_object_cache;
487
+
488
+		if ( isset( $wp_object_cache->cache[ $group ] ) ) {
489
+			foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
490
+				wp_cache_delete($k, $group);
491
+			}
492
+			return true;
493
+		}
494
+
495
+		return false;
496
+	}
497
+
498
+	/**
499
+	 * Check a value from a shortcode to see if true or false.
500
+	 * True when value is 1, true, 'true', 'yes'
501
+	 *
502
+	 * @since 1.07.10
503
+	 *
504
+	 * @param string $value The value to compare
505
+	 * @return boolean True or False
506
+	 */
507 507
 	public static function is_true( $value ) {
508
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
509
-    }
508
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
509
+	}
510 510
 
511
-    /**
512
-     * Used to filter shortcode in text widgets
513
-     */
514
-    public static function widget_text_filter_callback( $matches ) {
515
-        return do_shortcode( $matches[0] );
516
-    }
511
+	/**
512
+	 * Used to filter shortcode in text widgets
513
+	 */
514
+	public static function widget_text_filter_callback( $matches ) {
515
+		return do_shortcode( $matches[0] );
516
+	}
517 517
 
518 518
 	public static function load_scripts( $scripts ) {
519
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
520
-        foreach ( (array) $scripts as $s ) {
521
-            wp_enqueue_script($s);
522
-        }
523
-    }
519
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
520
+		foreach ( (array) $scripts as $s ) {
521
+			wp_enqueue_script($s);
522
+		}
523
+	}
524 524
 
525 525
 	public static function load_styles( $styles ) {
526
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
527
-        foreach ( (array) $styles as $s ) {
528
-            wp_enqueue_style($s);
529
-        }
530
-    }
526
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
527
+		foreach ( (array) $styles as $s ) {
528
+			wp_enqueue_style($s);
529
+		}
530
+	}
531 531
 
532
-    public static function get_pages() {
532
+	public static function get_pages() {
533 533
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
534
-    }
534
+	}
535 535
 
536
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
537
-        $pages = self::get_pages();
536
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
537
+		$pages = self::get_pages();
538 538
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
539
-    ?>
539
+	?>
540 540
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
541 541
             <option value=""> </option>
542 542
             <?php foreach ( $pages as $page ) { ?>
@@ -546,107 +546,107 @@  discard block
 block discarded – undo
546 546
             <?php } ?>
547 547
         </select>
548 548
     <?php
549
-    }
549
+	}
550 550
 
551 551
 	public static function post_edit_link( $post_id ) {
552
-        $post = get_post($post_id);
553
-        if ( $post ) {
552
+		$post = get_post($post_id);
553
+		if ( $post ) {
554 554
 			return '<a href="'. esc_url( admin_url('post.php?post='. $post_id .'&action=edit') ) .'">'. self::truncate( $post->post_title, 50 ) .'</a>';
555
-        }
556
-        return '';
557
-    }
555
+		}
556
+		return '';
557
+	}
558 558
 
559 559
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
560
-    ?>
560
+	?>
561 561
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
562
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
563
-            ?> class="frm_multiselect">
562
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
563
+			?> class="frm_multiselect">
564 564
             <?php self::roles_options($capability); ?>
565 565
         </select>
566 566
     <?php
567
-    }
567
+	}
568 568
 
569 569
 	public static function roles_options( $capability ) {
570
-        global $frm_vars;
571
-        if ( isset($frm_vars['editable_roles']) ) {
572
-            $editable_roles = $frm_vars['editable_roles'];
573
-        } else {
574
-            $editable_roles = get_editable_roles();
575
-            $frm_vars['editable_roles'] = $editable_roles;
576
-        }
577
-
578
-        foreach ( $editable_roles as $role => $details ) {
579
-            $name = translate_user_role($details['name'] ); ?>
570
+		global $frm_vars;
571
+		if ( isset($frm_vars['editable_roles']) ) {
572
+			$editable_roles = $frm_vars['editable_roles'];
573
+		} else {
574
+			$editable_roles = get_editable_roles();
575
+			$frm_vars['editable_roles'] = $editable_roles;
576
+		}
577
+
578
+		foreach ( $editable_roles as $role => $details ) {
579
+			$name = translate_user_role($details['name'] ); ?>
580 580
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
581 581
 <?php
582
-            unset($role, $details);
583
-        }
584
-    }
582
+			unset($role, $details);
583
+		}
584
+	}
585 585
 
586 586
 	public static function frm_capabilities( $type = 'auto' ) {
587
-        $cap = array(
588
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
589
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
590
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
591
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
592
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
593
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
594
-        );
587
+		$cap = array(
588
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
589
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
590
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
591
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
592
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
593
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
594
+		);
595 595
 
596 596
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
597
-            return $cap;
598
-        }
597
+			return $cap;
598
+		}
599 599
 
600
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
601
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
602
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
603
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
600
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
601
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
602
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
603
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
604 604
 
605
-        return $cap;
606
-    }
605
+		return $cap;
606
+	}
607 607
 
608 608
 	public static function user_has_permission( $needed_role ) {
609
-        if ( $needed_role == '-1' ) {
610
-            return false;
609
+		if ( $needed_role == '-1' ) {
610
+			return false;
611 611
 		}
612 612
 
613
-        // $needed_role will be equal to blank if "Logged-in users" is selected
614
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
615
-            return true;
616
-        }
613
+		// $needed_role will be equal to blank if "Logged-in users" is selected
614
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
615
+			return true;
616
+		}
617 617
 
618
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
619
-        foreach ( $roles as $role ) {
618
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
619
+		foreach ( $roles as $role ) {
620 620
 			if ( current_user_can( $role ) ) {
621
-        		return true;
621
+				return true;
622 622
 			}
623
-        	if ( $role == $needed_role ) {
624
-        		break;
623
+			if ( $role == $needed_role ) {
624
+				break;
625 625
 			}
626
-        }
627
-        return false;
628
-    }
629
-
630
-    /**
631
-     * Make sure administrators can see Formidable menu
632
-     *
633
-     * @since 2.0
634
-     */
635
-    public static function maybe_add_permissions() {
626
+		}
627
+		return false;
628
+	}
629
+
630
+	/**
631
+	 * Make sure administrators can see Formidable menu
632
+	 *
633
+	 * @since 2.0
634
+	 */
635
+	public static function maybe_add_permissions() {
636 636
 		self::force_capability( 'frm_view_entries' );
637 637
 
638
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
639
-            return;
640
-        }
638
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
639
+			return;
640
+		}
641 641
 
642 642
 		$user_id = get_current_user_id();
643 643
 		$user = new WP_User( $user_id );
644
-        $frm_roles = self::frm_capabilities();
645
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
644
+		$frm_roles = self::frm_capabilities();
645
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
646 646
 			$user->add_cap( $frm_role );
647
-            unset($frm_role, $frm_role_description);
648
-        }
649
-    }
647
+			unset($frm_role, $frm_role_description);
648
+		}
649
+	}
650 650
 
651 651
 	/**
652 652
 	 * Make sure admins have permission to see the menu items
@@ -662,28 +662,28 @@  discard block
 block discarded – undo
662 662
 		}
663 663
 	}
664 664
 
665
-    /**
666
-     * Check if the user has permision for action.
667
-     * Return permission message and stop the action if no permission
668
-     * @since 2.0
669
-     * @param string $permission
670
-     */
665
+	/**
666
+	 * Check if the user has permision for action.
667
+	 * Return permission message and stop the action if no permission
668
+	 * @since 2.0
669
+	 * @param string $permission
670
+	 */
671 671
 	public static function permission_check( $permission, $show_message = 'show' ) {
672
-        $permission_error = self::permission_nonce_error($permission);
673
-        if ( $permission_error !== false ) {
674
-            if ( 'hide' == $show_message ) {
675
-                $permission_error = '';
676
-            }
677
-            wp_die($permission_error);
678
-        }
679
-    }
680
-
681
-    /**
682
-     * Check user permission and nonce
683
-     * @since 2.0
684
-     * @param string $permission
685
-     * @return false|string The permission message or false if allowed
686
-     */
672
+		$permission_error = self::permission_nonce_error($permission);
673
+		if ( $permission_error !== false ) {
674
+			if ( 'hide' == $show_message ) {
675
+				$permission_error = '';
676
+			}
677
+			wp_die($permission_error);
678
+		}
679
+	}
680
+
681
+	/**
682
+	 * Check user permission and nonce
683
+	 * @since 2.0
684
+	 * @param string $permission
685
+	 * @return false|string The permission message or false if allowed
686
+	 */
687 687
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
688 688
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
689 689
 			$frm_settings = self::get_settings();
@@ -691,75 +691,75 @@  discard block
 block discarded – undo
691 691
 		}
692 692
 
693 693
 		$error = false;
694
-        if ( empty($nonce_name) ) {
695
-            return $error;
696
-        }
694
+		if ( empty($nonce_name) ) {
695
+			return $error;
696
+		}
697 697
 
698
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
699
-            $frm_settings = self::get_settings();
700
-            $error = $frm_settings->admin_permission;
701
-        }
698
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
699
+			$frm_settings = self::get_settings();
700
+			$error = $frm_settings->admin_permission;
701
+		}
702 702
 
703
-        return $error;
704
-    }
703
+		return $error;
704
+	}
705 705
 
706
-    public static function checked( $values, $current ) {
706
+	public static function checked( $values, $current ) {
707 707
 		if ( self::check_selected( $values, $current ) ) {
708
-            echo ' checked="checked"';
708
+			echo ' checked="checked"';
709 709
 		}
710
-    }
710
+	}
711 711
 
712 712
 	public static function check_selected( $values, $current ) {
713
-        $values = self::recursive_function_map( $values, 'trim' );
714
-        $current = trim($current);
715
-
716
-        return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
717
-    }
718
-
719
-    /**
720
-    * Check if current field option is an "other" option
721
-    *
722
-    * @since 2.0
723
-    *
724
-    * @param string $opt_key
725
-    * @return boolean Returns true if current field option is an "Other" option
726
-    */
727
-    public static function is_other_opt( $opt_key ) {
728
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
729
-        return FrmFieldsHelper::is_other_opt( $opt_key );
730
-    }
731
-
732
-    /**
733
-    * Get value that belongs in "Other" text box
734
-    *
735
-    * @since 2.0
736
-    *
737
-    * @param string $opt_key
738
-    * @param array $field
739
-    * @return string $other_val
740
-    */
741
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
713
+		$values = self::recursive_function_map( $values, 'trim' );
714
+		$current = trim($current);
715
+
716
+		return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
717
+	}
718
+
719
+	/**
720
+	 * Check if current field option is an "other" option
721
+	 *
722
+	 * @since 2.0
723
+	 *
724
+	 * @param string $opt_key
725
+	 * @return boolean Returns true if current field option is an "Other" option
726
+	 */
727
+	public static function is_other_opt( $opt_key ) {
728
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
729
+		return FrmFieldsHelper::is_other_opt( $opt_key );
730
+	}
731
+
732
+	/**
733
+	 * Get value that belongs in "Other" text box
734
+	 *
735
+	 * @since 2.0
736
+	 *
737
+	 * @param string $opt_key
738
+	 * @param array $field
739
+	 * @return string $other_val
740
+	 */
741
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
742 742
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
743 743
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
744
-    }
745
-
746
-    /**
747
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
748
-    * Intended for front-end use
749
-    *
750
-    * @since 2.0
751
-    *
752
-    * @param array $field
753
-    * @param boolean $other_opt
754
-    * @param string $checked
755
-    * @param array $args should include opt_key and field name
756
-    * @return string $other_val
757
-    */
758
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
744
+	}
745
+
746
+	/**
747
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
748
+	 * Intended for front-end use
749
+	 *
750
+	 * @since 2.0
751
+	 *
752
+	 * @param array $field
753
+	 * @param boolean $other_opt
754
+	 * @param string $checked
755
+	 * @param array $args should include opt_key and field name
756
+	 * @return string $other_val
757
+	 */
758
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
759 759
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
760 760
 		$args['field'] = $field;
761 761
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
762
-    }
762
+	}
763 763
 
764 764
 	public static function recursive_function_map( $value, $function ) {
765 765
 		if ( is_array( $value ) ) {
@@ -789,331 +789,331 @@  discard block
 block discarded – undo
789 789
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
790 790
 	}
791 791
 
792
-    /**
793
-     * Flatten a multi-dimensional array
794
-     */
792
+	/**
793
+	 * Flatten a multi-dimensional array
794
+	 */
795 795
 	public static function array_flatten( $array, $keys = 'keep' ) {
796
-        $return = array();
797
-        foreach ( $array as $key => $value ) {
798
-            if ( is_array($value) ) {
796
+		$return = array();
797
+		foreach ( $array as $key => $value ) {
798
+			if ( is_array($value) ) {
799 799
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
800
-            } else {
800
+			} else {
801 801
 				if ( $keys == 'keep' ) {
802 802
 					$return[ $key ] = $value;
803 803
 				} else {
804 804
 					$return[] = $value;
805 805
 				}
806
-            }
807
-        }
808
-        return $return;
809
-    }
810
-
811
-    public static function esc_textarea( $text ) {
812
-        $safe_text = str_replace('&quot;', '"', $text);
813
-        $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
814
-    	return apply_filters( 'esc_textarea', $safe_text, $text );
815
-    }
816
-
817
-    /**
818
-     * Add auto paragraphs to text areas
819
-     * @since 2.0
820
-     */
806
+			}
807
+		}
808
+		return $return;
809
+	}
810
+
811
+	public static function esc_textarea( $text ) {
812
+		$safe_text = str_replace('&quot;', '"', $text);
813
+		$safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
814
+		return apply_filters( 'esc_textarea', $safe_text, $text );
815
+	}
816
+
817
+	/**
818
+	 * Add auto paragraphs to text areas
819
+	 * @since 2.0
820
+	 */
821 821
 	public static function use_wpautop( $content ) {
822
-        if ( apply_filters('frm_use_wpautop', true) ) {
823
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
824
-        }
825
-        return $content;
826
-    }
822
+		if ( apply_filters('frm_use_wpautop', true) ) {
823
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
824
+		}
825
+		return $content;
826
+	}
827 827
 
828 828
 	public static function replace_quotes( $val ) {
829
-        //Replace double quotes
829
+		//Replace double quotes
830 830
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
831
-        //Replace single quotes
832
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
833
-        return $val;
834
-    }
835
-
836
-    /**
837
-     * @since 2.0
838
-     * @return string The base Google APIS url for the current version of jQuery UI
839
-     */
840
-    public static function jquery_ui_base_url() {
841
-        $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
842
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
843
-        return $url;
844
-    }
845
-
846
-    /**
847
-     * @param string $handle
848
-     */
831
+		//Replace single quotes
832
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
833
+		return $val;
834
+	}
835
+
836
+	/**
837
+	 * @since 2.0
838
+	 * @return string The base Google APIS url for the current version of jQuery UI
839
+	 */
840
+	public static function jquery_ui_base_url() {
841
+		$url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
842
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
843
+		return $url;
844
+	}
845
+
846
+	/**
847
+	 * @param string $handle
848
+	 */
849 849
 	public static function script_version( $handle ) {
850
-        global $wp_scripts;
851
-    	if ( ! $wp_scripts ) {
852
-    	    return false;
853
-    	}
850
+		global $wp_scripts;
851
+		if ( ! $wp_scripts ) {
852
+			return false;
853
+		}
854 854
 
855
-        $ver = 0;
855
+		$ver = 0;
856 856
 
857
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
858
-            return $ver;
859
-        }
857
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
858
+			return $ver;
859
+		}
860 860
 
861
-        $query = $wp_scripts->registered[ $handle ];
862
-    	if ( is_object( $query ) ) {
863
-    	    $ver = $query->ver;
864
-    	}
861
+		$query = $wp_scripts->registered[ $handle ];
862
+		if ( is_object( $query ) ) {
863
+			$ver = $query->ver;
864
+		}
865 865
 
866
-    	return $ver;
867
-    }
866
+		return $ver;
867
+	}
868 868
 
869 869
 	public static function js_redirect( $url ) {
870 870
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
871
-    }
871
+	}
872 872
 
873 873
 	public static function get_user_id_param( $user_id ) {
874
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
875
-            return $user_id;
876
-        }
874
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
875
+			return $user_id;
876
+		}
877 877
 
878 878
 		if ( $user_id == 'current' ) {
879 879
 			$user_id = get_current_user_id();
880 880
 		} else {
881
-            if ( is_email($user_id) ) {
882
-                $user = get_user_by('email', $user_id);
883
-            } else {
884
-                $user = get_user_by('login', $user_id);
885
-            }
881
+			if ( is_email($user_id) ) {
882
+				$user = get_user_by('email', $user_id);
883
+			} else {
884
+				$user = get_user_by('login', $user_id);
885
+			}
886 886
 
887
-            if ( $user ) {
888
-                $user_id = $user->ID;
889
-            }
890
-            unset($user);
891
-        }
887
+			if ( $user ) {
888
+				$user_id = $user->ID;
889
+			}
890
+			unset($user);
891
+		}
892 892
 
893
-        return $user_id;
894
-    }
893
+		return $user_id;
894
+	}
895 895
 
896 896
 	public static function get_file_contents( $filename, $atts = array() ) {
897
-        if ( ! is_file($filename) ) {
898
-            return false;
899
-        }
900
-
901
-        extract($atts);
902
-        ob_start();
903
-        include($filename);
904
-        $contents = ob_get_contents();
905
-        ob_end_clean();
906
-        return $contents;
907
-    }
908
-
909
-    /**
910
-     * @param string $table_name
911
-     * @param string $column
912
-     */
913
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) {
914
-        $key = '';
915
-
916
-        if ( ! empty( $name ) ) {
917
-            $key = sanitize_key($name);
918
-        }
897
+		if ( ! is_file($filename) ) {
898
+			return false;
899
+		}
900
+
901
+		extract($atts);
902
+		ob_start();
903
+		include($filename);
904
+		$contents = ob_get_contents();
905
+		ob_end_clean();
906
+		return $contents;
907
+	}
908
+
909
+	/**
910
+	 * @param string $table_name
911
+	 * @param string $column
912
+	 */
913
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) {
914
+		$key = '';
915
+
916
+		if ( ! empty( $name ) ) {
917
+			$key = sanitize_key($name);
918
+		}
919 919
 
920 920
 		if ( empty( $key ) ) {
921
-            $max_slug_value = pow(36, $num_chars);
922
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
923
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
924
-        }
921
+			$max_slug_value = pow(36, $num_chars);
922
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
923
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
924
+		}
925 925
 
926 926
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
927
-            $key = $key .'a';
928
-        }
927
+			$key = $key .'a';
928
+		}
929 929
 
930 930
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
931 931
 
932
-        if ( $key_check || is_numeric($key_check) ) {
933
-            $suffix = 2;
932
+		if ( $key_check || is_numeric($key_check) ) {
933
+			$suffix = 2;
934 934
 			do {
935 935
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
936 936
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
937 937
 				$suffix++;
938 938
 			} while ($key_check || is_numeric($key_check));
939 939
 			$key = $alt_post_name;
940
-        }
941
-        return $key;
942
-    }
943
-
944
-    /**
945
-     * Editing a Form or Entry
946
-     * @param string $table
947
-     * @return bool|array
948
-     */
949
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
950
-        if ( ! $record ) {
951
-            return false;
952
-        }
953
-
954
-        global $frm_vars;
955
-
956
-        if ( empty($post_values) ) {
957
-            $post_values = stripslashes_deep($_POST);
958
-        }
940
+		}
941
+		return $key;
942
+	}
943
+
944
+	/**
945
+	 * Editing a Form or Entry
946
+	 * @param string $table
947
+	 * @return bool|array
948
+	 */
949
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
950
+		if ( ! $record ) {
951
+			return false;
952
+		}
953
+
954
+		global $frm_vars;
955
+
956
+		if ( empty($post_values) ) {
957
+			$post_values = stripslashes_deep($_POST);
958
+		}
959 959
 
960 960
 		$values = array( 'id' => $record->id, 'fields' => array() );
961 961
 
962 962
 		foreach ( array( 'name', 'description' ) as $var ) {
963
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
964
-            $values[ $var ] = self::get_param( $var, $default_val );
965
-            unset($var, $default_val);
966
-        }
967
-
968
-        $values['description'] = self::use_wpautop($values['description']);
969
-        $frm_settings = self::get_settings();
970
-        $is_form_builder = self::is_admin_page('formidable' );
971
-
972
-        foreach ( (array) $fields as $field ) {
973
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
974
-            if ( ! $is_form_builder ) {
975
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
976
-            }
963
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
964
+			$values[ $var ] = self::get_param( $var, $default_val );
965
+			unset($var, $default_val);
966
+		}
967
+
968
+		$values['description'] = self::use_wpautop($values['description']);
969
+		$frm_settings = self::get_settings();
970
+		$is_form_builder = self::is_admin_page('formidable' );
971
+
972
+		foreach ( (array) $fields as $field ) {
973
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
974
+			if ( ! $is_form_builder ) {
975
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
976
+			}
977 977
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
978 978
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
979
-        }
979
+		}
980 980
 
981
-        self::fill_form_opts($record, $table, $post_values, $values);
981
+		self::fill_form_opts($record, $table, $post_values, $values);
982 982
 
983
-        if ( $table == 'entries' ) {
984
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
985
-        } else if ( $table == 'forms' ) {
986
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
987
-        }
983
+		if ( $table == 'entries' ) {
984
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
985
+		} else if ( $table == 'forms' ) {
986
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
987
+		}
988 988
 
989
-        return $values;
990
-    }
989
+		return $values;
990
+	}
991 991
 
992 992
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
993
-        $post_values = $args['post_values'];
994
-
995
-        if ( $args['default'] ) {
996
-            $meta_value = $field->default_value;
997
-        } else {
998
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
999
-                if ( ! isset($field->field_options['custom_field']) ) {
1000
-                    $field->field_options['custom_field'] = '';
1001
-                }
993
+		$post_values = $args['post_values'];
994
+
995
+		if ( $args['default'] ) {
996
+			$meta_value = $field->default_value;
997
+		} else {
998
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
999
+				if ( ! isset($field->field_options['custom_field']) ) {
1000
+					$field->field_options['custom_field'] = '';
1001
+				}
1002 1002
 				$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 ) );
1003
-            } else {
1003
+			} else {
1004 1004
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1005
-            }
1006
-        }
1007
-
1008
-        $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
1009
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1010
-
1011
-        $field_array = array(
1012
-            'id'            => $field->id,
1013
-            'value'         => $new_value,
1014
-            'default_value' => $field->default_value,
1015
-            'name'          => $field->name,
1016
-            'description'   => $field->description,
1017
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1018
-            'options'       => $field->options,
1019
-            'required'      => $field->required,
1020
-            'field_key'     => $field->field_key,
1021
-            'field_order'   => $field->field_order,
1022
-            'form_id'       => $field->form_id,
1005
+			}
1006
+		}
1007
+
1008
+		$field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
1009
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1010
+
1011
+		$field_array = array(
1012
+			'id'            => $field->id,
1013
+			'value'         => $new_value,
1014
+			'default_value' => $field->default_value,
1015
+			'name'          => $field->name,
1016
+			'description'   => $field->description,
1017
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1018
+			'options'       => $field->options,
1019
+			'required'      => $field->required,
1020
+			'field_key'     => $field->field_key,
1021
+			'field_order'   => $field->field_order,
1022
+			'form_id'       => $field->form_id,
1023 1023
 			'parent_form_id' => $args['parent_form_id'],
1024
-        );
1024
+		);
1025 1025
 
1026
-        $args['field_type'] = $field_type;
1027
-        self::fill_field_opts($field, $field_array, $args);
1026
+		$args['field_type'] = $field_type;
1027
+		self::fill_field_opts($field, $field_array, $args);
1028 1028
 
1029
-        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1029
+		$field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1030 1030
 
1031
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1032
-            $field_array['unique_msg'] = '';
1033
-        }
1031
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1032
+			$field_array['unique_msg'] = '';
1033
+		}
1034 1034
 
1035
-        $field_array = array_merge( $field->field_options, $field_array );
1035
+		$field_array = array_merge( $field->field_options, $field_array );
1036 1036
 
1037
-        $values['fields'][ $field->id ] = $field_array;
1038
-    }
1037
+		$values['fields'][ $field->id ] = $field_array;
1038
+	}
1039 1039
 
1040 1040
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1041
-        $post_values = $args['post_values'];
1042
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1043
-
1044
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1045
-            $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 );
1046
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1047
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1048
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1049
-                if ( $args['field_type'] == 'captcha' ) {
1050
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1051
-                } else {
1052
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1053
-                }
1054
-            }
1055
-        }
1056
-
1057
-        if ( $field_array['custom_html'] == '' ) {
1058
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1059
-        }
1060
-    }
1061
-
1062
-    /**
1063
-     * @param string $table
1064
-     */
1041
+		$post_values = $args['post_values'];
1042
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1043
+
1044
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1045
+			$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 );
1046
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1047
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1048
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1049
+				if ( $args['field_type'] == 'captcha' ) {
1050
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1051
+				} else {
1052
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1053
+				}
1054
+			}
1055
+		}
1056
+
1057
+		if ( $field_array['custom_html'] == '' ) {
1058
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1059
+		}
1060
+	}
1061
+
1062
+	/**
1063
+	 * @param string $table
1064
+	 */
1065 1065
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1066
-        if ( $table == 'entries' ) {
1067
-            $form = $record->form_id;
1066
+		if ( $table == 'entries' ) {
1067
+			$form = $record->form_id;
1068 1068
 			FrmForm::maybe_get_form( $form );
1069
-        } else {
1070
-            $form = $record;
1071
-        }
1069
+		} else {
1070
+			$form = $record;
1071
+		}
1072 1072
 
1073
-        if ( ! $form ) {
1074
-            return;
1075
-        }
1073
+		if ( ! $form ) {
1074
+			return;
1075
+		}
1076 1076
 
1077
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1077
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1078 1078
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1079 1079
 
1080
-        if ( ! is_array($form->options) ) {
1081
-            return;
1082
-        }
1080
+		if ( ! is_array($form->options) ) {
1081
+			return;
1082
+		}
1083 1083
 
1084
-        foreach ( $form->options as $opt => $value ) {
1085
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1086
-        }
1084
+		foreach ( $form->options as $opt => $value ) {
1085
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1086
+		}
1087 1087
 
1088
-        self::fill_form_defaults($post_values, $values);
1089
-    }
1088
+		self::fill_form_defaults($post_values, $values);
1089
+	}
1090 1090
 
1091
-    /**
1092
-     * Set to POST value or default
1093
-     */
1091
+	/**
1092
+	 * Set to POST value or default
1093
+	 */
1094 1094
 	private static function fill_form_defaults( $post_values, array &$values ) {
1095
-        $form_defaults = FrmFormsHelper::get_default_opts();
1095
+		$form_defaults = FrmFormsHelper::get_default_opts();
1096 1096
 
1097
-        foreach ( $form_defaults as $opt => $default ) {
1098
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1097
+		foreach ( $form_defaults as $opt => $default ) {
1098
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1099 1099
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1100
-            }
1100
+			}
1101 1101
 
1102
-            unset($opt, $defaut);
1103
-        }
1102
+			unset($opt, $defaut);
1103
+		}
1104 1104
 
1105
-        if ( ! isset($values['custom_style']) ) {
1106
-            $frm_settings = self::get_settings();
1105
+		if ( ! isset($values['custom_style']) ) {
1106
+			$frm_settings = self::get_settings();
1107 1107
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1108
-        }
1108
+		}
1109 1109
 
1110 1110
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1111
-            if ( ! isset( $values[ $h .'_html' ] ) ) {
1112
-                $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1113
-            }
1114
-            unset($h);
1115
-        }
1116
-    }
1111
+			if ( ! isset( $values[ $h .'_html' ] ) ) {
1112
+				$values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1113
+			}
1114
+			unset($h);
1115
+		}
1116
+	}
1117 1117
 
1118 1118
 	public static function get_meta_value( $field_id, $entry ) {
1119 1119
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1121,69 +1121,69 @@  discard block
 block discarded – undo
1121 1121
 	}
1122 1122
 
1123 1123
 	public static function insert_opt_html( $args ) {
1124
-        $class = '';
1125
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1126
-            $class .= 'show_frm_not_email_to';
1127
-        }
1128
-    ?>
1124
+		$class = '';
1125
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1126
+			$class .= 'show_frm_not_email_to';
1127
+		}
1128
+	?>
1129 1129
 <li>
1130 1130
     <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>
1131 1131
     <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>
1132 1132
     <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>
1133 1133
 </li>
1134 1134
     <?php
1135
-    }
1135
+	}
1136 1136
 
1137
-    public static function get_us_states() {
1138
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1139
-        return FrmFieldsHelper::get_us_states();
1140
-    }
1137
+	public static function get_us_states() {
1138
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1139
+		return FrmFieldsHelper::get_us_states();
1140
+	}
1141 1141
 
1142
-    public static function get_countries() {
1143
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1144
-        return FrmFieldsHelper::get_countries();
1145
-    }
1142
+	public static function get_countries() {
1143
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1144
+		return FrmFieldsHelper::get_countries();
1145
+	}
1146 1146
 
1147 1147
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1148
-        if ( is_array( $str ) ) {
1149
-            return;
1148
+		if ( is_array( $str ) ) {
1149
+			return;
1150 1150
 		}
1151 1151
 
1152
-        $length = (int) $length;
1152
+		$length = (int) $length;
1153 1153
 		$str = wp_strip_all_tags( $str );
1154 1154
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1155 1155
 
1156 1156
 		if ( $length == 0 ) {
1157
-            return '';
1158
-        } else if ( $length <= 10 ) {
1157
+			return '';
1158
+		} else if ( $length <= 10 ) {
1159 1159
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1160
-            return $sub . (($length < $original_len) ? $continue : '');
1161
-        }
1160
+			return $sub . (($length < $original_len) ? $continue : '');
1161
+		}
1162 1162
 
1163
-        $sub = '';
1164
-        $len = 0;
1163
+		$sub = '';
1164
+		$len = 0;
1165 1165
 
1166 1166
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1167 1167
 
1168 1168
 		foreach ( $words as $word ) {
1169
-            $part = (($sub != '') ? ' ' : '') . $word;
1169
+			$part = (($sub != '') ? ' ' : '') . $word;
1170 1170
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1171
-            if ( $total_len > $length && str_word_count($sub) ) {
1172
-                break;
1173
-            }
1171
+			if ( $total_len > $length && str_word_count($sub) ) {
1172
+				break;
1173
+			}
1174 1174
 
1175
-            $sub .= $part;
1175
+			$sub .= $part;
1176 1176
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1177 1177
 
1178
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1179
-                break;
1180
-            }
1178
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1179
+				break;
1180
+			}
1181 1181
 
1182
-            unset($total_len, $word);
1183
-        }
1182
+			unset($total_len, $word);
1183
+		}
1184 1184
 
1185
-        return $sub . (($len < $original_len) ? $continue : '');
1186
-    }
1185
+		return $sub . (($len < $original_len) ? $continue : '');
1186
+	}
1187 1187
 
1188 1188
 	public static function mb_function( $function_names, $args ) {
1189 1189
 		$mb_function_name = $function_names[0];
@@ -1195,18 +1195,18 @@  discard block
 block discarded – undo
1195 1195
 	}
1196 1196
 
1197 1197
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1198
-        if ( empty($date) ) {
1199
-            return $date;
1200
-        }
1198
+		if ( empty($date) ) {
1199
+			return $date;
1200
+		}
1201 1201
 
1202
-        if ( empty($date_format) ) {
1203
-            $date_format = get_option('date_format');
1204
-        }
1202
+		if ( empty($date_format) ) {
1203
+			$date_format = get_option('date_format');
1204
+		}
1205 1205
 
1206
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1207
-            $frmpro_settings = new FrmProSettings();
1208
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1209
-        }
1206
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1207
+			$frmpro_settings = new FrmProSettings();
1208
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1209
+		}
1210 1210
 
1211 1211
 		$formatted = self::get_localized_date( $date_format, $date );
1212 1212
 
@@ -1215,8 +1215,8 @@  discard block
 block discarded – undo
1215 1215
 			$formatted .= self::add_time_to_date( $time_format, $date );
1216 1216
 		}
1217 1217
 
1218
-        return $formatted;
1219
-    }
1218
+		return $formatted;
1219
+	}
1220 1220
 
1221 1221
 	private static function add_time_to_date( $time_format, $date ) {
1222 1222
 		if ( empty( $time_format ) ) {
@@ -1297,61 +1297,61 @@  discard block
 block discarded – undo
1297 1297
 		);
1298 1298
 	}
1299 1299
 
1300
-    /**
1301
-     * Added for < WP 4.0 compatability
1302
-     *
1303
-     * @since 1.07.10
1304
-     *
1305
-     * @param string $term The value to escape
1306
-     * @return string The escaped value
1307
-     */
1300
+	/**
1301
+	 * Added for < WP 4.0 compatability
1302
+	 *
1303
+	 * @since 1.07.10
1304
+	 *
1305
+	 * @param string $term The value to escape
1306
+	 * @return string The escaped value
1307
+	 */
1308 1308
 	public static function esc_like( $term ) {
1309
-        global $wpdb;
1310
-        if ( method_exists($wpdb, 'esc_like') ) {
1309
+		global $wpdb;
1310
+		if ( method_exists($wpdb, 'esc_like') ) {
1311 1311
 			// WP 4.0
1312
-            $term = $wpdb->esc_like( $term );
1313
-        } else {
1314
-            $term = like_escape( $term );
1315
-        }
1312
+			$term = $wpdb->esc_like( $term );
1313
+		} else {
1314
+			$term = like_escape( $term );
1315
+		}
1316 1316
 
1317
-        return $term;
1318
-    }
1317
+		return $term;
1318
+	}
1319 1319
 
1320
-    /**
1321
-     * @param string $order_query
1322
-     */
1320
+	/**
1321
+	 * @param string $order_query
1322
+	 */
1323 1323
 	public static function esc_order( $order_query ) {
1324
-        if ( empty($order_query) ) {
1325
-            return '';
1326
-        }
1327
-
1328
-        // remove ORDER BY before santizing
1329
-        $order_query = strtolower($order_query);
1330
-        if ( strpos($order_query, 'order by') !== false ) {
1331
-            $order_query = str_replace('order by', '', $order_query);
1332
-        }
1333
-
1334
-        $order_query = explode(' ', trim($order_query));
1335
-
1336
-        $order_fields = array(
1337
-            'id', 'form_key', 'name', 'description',
1338
-            'parent_form_id', 'logged_in', 'is_template',
1339
-            'default_template', 'status', 'created_at',
1340
-        );
1341
-
1342
-        $order = trim(trim(reset($order_query), ','));
1343
-        if ( ! in_array($order, $order_fields) ) {
1344
-            return '';
1345
-        }
1346
-
1347
-        $order_by = '';
1348
-        if ( count($order_query) > 1 ) {
1324
+		if ( empty($order_query) ) {
1325
+			return '';
1326
+		}
1327
+
1328
+		// remove ORDER BY before santizing
1329
+		$order_query = strtolower($order_query);
1330
+		if ( strpos($order_query, 'order by') !== false ) {
1331
+			$order_query = str_replace('order by', '', $order_query);
1332
+		}
1333
+
1334
+		$order_query = explode(' ', trim($order_query));
1335
+
1336
+		$order_fields = array(
1337
+			'id', 'form_key', 'name', 'description',
1338
+			'parent_form_id', 'logged_in', 'is_template',
1339
+			'default_template', 'status', 'created_at',
1340
+		);
1341
+
1342
+		$order = trim(trim(reset($order_query), ','));
1343
+		if ( ! in_array($order, $order_fields) ) {
1344
+			return '';
1345
+		}
1346
+
1347
+		$order_by = '';
1348
+		if ( count($order_query) > 1 ) {
1349 1349
 			$order_by = end( $order_query );
1350 1350
 			self::esc_order_by( $order_by );
1351
-        }
1351
+		}
1352 1352
 
1353
-        return ' ORDER BY '. $order . ' '. $order_by;
1354
-    }
1353
+		return ' ORDER BY '. $order . ' '. $order_by;
1354
+	}
1355 1355
 
1356 1356
 	/**
1357 1357
 	 * Make sure this is ordering by either ASC or DESC
@@ -1363,183 +1363,183 @@  discard block
 block discarded – undo
1363 1363
 		}
1364 1364
 	}
1365 1365
 
1366
-    /**
1367
-     * @param string $limit
1368
-     */
1366
+	/**
1367
+	 * @param string $limit
1368
+	 */
1369 1369
 	public static function esc_limit( $limit ) {
1370
-        if ( empty($limit) ) {
1371
-            return '';
1372
-        }
1373
-
1374
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1375
-        if ( is_numeric($limit) ) {
1376
-            return ' LIMIT '. $limit;
1377
-        }
1378
-
1379
-        $limit = explode(',', trim($limit));
1380
-        foreach ( $limit as $k => $l ) {
1381
-            if ( is_numeric( $l ) ) {
1382
-                $limit[ $k ] = $l;
1383
-            }
1384
-        }
1385
-
1386
-        $limit = implode(',', $limit);
1387
-        return ' LIMIT '. $limit;
1388
-    }
1389
-
1390
-    /**
1391
-     * Get an array of values ready to go through $wpdb->prepare
1392
-     * @since 2.0
1393
-     */
1394
-    public static function prepare_array_values( $array, $type = '%s' ) {
1395
-        $placeholders = array_fill(0, count($array), $type);
1396
-        return implode(', ', $placeholders);
1397
-    }
1398
-
1399
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1400
-        if ( empty($where) ) {
1401
-            return '';
1402
-        }
1370
+		if ( empty($limit) ) {
1371
+			return '';
1372
+		}
1373
+
1374
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1375
+		if ( is_numeric($limit) ) {
1376
+			return ' LIMIT '. $limit;
1377
+		}
1378
+
1379
+		$limit = explode(',', trim($limit));
1380
+		foreach ( $limit as $k => $l ) {
1381
+			if ( is_numeric( $l ) ) {
1382
+				$limit[ $k ] = $l;
1383
+			}
1384
+		}
1385
+
1386
+		$limit = implode(',', $limit);
1387
+		return ' LIMIT '. $limit;
1388
+	}
1389
+
1390
+	/**
1391
+	 * Get an array of values ready to go through $wpdb->prepare
1392
+	 * @since 2.0
1393
+	 */
1394
+	public static function prepare_array_values( $array, $type = '%s' ) {
1395
+		$placeholders = array_fill(0, count($array), $type);
1396
+		return implode(', ', $placeholders);
1397
+	}
1398
+
1399
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1400
+		if ( empty($where) ) {
1401
+			return '';
1402
+		}
1403 1403
 
1404 1404
 		if ( is_array( $where ) ) {
1405
-            global $wpdb;
1406
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1405
+			global $wpdb;
1406
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1407 1407
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1408 1408
 		} else {
1409
-            $where = $starts_with . $where;
1410
-        }
1409
+			$where = $starts_with . $where;
1410
+		}
1411 1411
 
1412
-        return $where;
1413
-    }
1412
+		return $where;
1413
+	}
1414 1414
 
1415
-    // Pagination Methods
1415
+	// Pagination Methods
1416 1416
 
1417
-    /**
1418
-     * @param integer $current_p
1419
-     */
1417
+	/**
1418
+	 * @param integer $current_p
1419
+	 */
1420 1420
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1421 1421
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1422 1422
 	}
1423 1423
 
1424
-    /**
1425
-     * @param integer $current_p
1426
-     */
1427
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1428
-        if ( $current_p == 1 ) {
1429
-            return 1;
1430
-        } else {
1431
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1432
-        }
1433
-    }
1434
-
1435
-    /**
1436
-     * @param string $table_name
1437
-     */
1438
-    public static function &getRecordCount( $where = '', $table_name ) {
1439
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1440
-        $count = FrmDb::get_count( $table_name, $where );
1441
-        return $count;
1442
-    }
1443
-
1444
-    public static function get_referer_info() {
1445
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1446
-        return self::get_server_value('HTTP_REFERER');
1447
-    }
1424
+	/**
1425
+	 * @param integer $current_p
1426
+	 */
1427
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1428
+		if ( $current_p == 1 ) {
1429
+			return 1;
1430
+		} else {
1431
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1432
+		}
1433
+	}
1434
+
1435
+	/**
1436
+	 * @param string $table_name
1437
+	 */
1438
+	public static function &getRecordCount( $where = '', $table_name ) {
1439
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1440
+		$count = FrmDb::get_count( $table_name, $where );
1441
+		return $count;
1442
+	}
1443
+
1444
+	public static function get_referer_info() {
1445
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1446
+		return self::get_server_value('HTTP_REFERER');
1447
+	}
1448 1448
 
1449 1449
 	/**
1450 1450
 	 * @return array
1451 1451
 	 */
1452 1452
 	public static function json_to_array( $json_vars ) {
1453
-        $vars = array();
1454
-        foreach ( $json_vars as $jv ) {
1455
-            $jv_name = explode('[', $jv['name']);
1456
-            $last = count($jv_name) - 1;
1457
-            foreach ( $jv_name as $p => $n ) {
1458
-                $name = trim($n, ']');
1459
-                if ( ! isset($l1) ) {
1460
-                    $l1 = $name;
1461
-                }
1462
-
1463
-                if ( ! isset($l2) ) {
1464
-                    $l2 = $name;
1465
-                }
1466
-
1467
-                if ( ! isset($l3) ) {
1468
-                    $l3 = $name;
1469
-                }
1470
-
1471
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1472
-
1473
-                switch ( $p ) {
1474
-                    case 0:
1475
-                        $l1 = $name;
1476
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1477
-                    break;
1478
-
1479
-                    case 1:
1480
-                        $l2 = $name;
1481
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1482
-                    break;
1483
-
1484
-                    case 2:
1485
-                        $l3 = $name;
1486
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1487
-                    break;
1488
-
1489
-                    case 3:
1490
-                        $l4 = $name;
1491
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1492
-                    break;
1493
-                }
1494
-
1495
-                unset($this_val, $n);
1496
-            }
1497
-
1498
-            unset($last, $jv);
1499
-        }
1500
-
1501
-        return $vars;
1502
-    }
1503
-
1504
-    /**
1505
-     * @param string $name
1506
-     * @param string $l1
1507
-     */
1508
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1509
-        if ( $name == '' ) {
1510
-            $vars[] = $val;
1511
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1512
-            $vars[ $l1 ] = $val;
1513
-        }
1514
-    }
1453
+		$vars = array();
1454
+		foreach ( $json_vars as $jv ) {
1455
+			$jv_name = explode('[', $jv['name']);
1456
+			$last = count($jv_name) - 1;
1457
+			foreach ( $jv_name as $p => $n ) {
1458
+				$name = trim($n, ']');
1459
+				if ( ! isset($l1) ) {
1460
+					$l1 = $name;
1461
+				}
1462
+
1463
+				if ( ! isset($l2) ) {
1464
+					$l2 = $name;
1465
+				}
1466
+
1467
+				if ( ! isset($l3) ) {
1468
+					$l3 = $name;
1469
+				}
1470
+
1471
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1472
+
1473
+				switch ( $p ) {
1474
+					case 0:
1475
+						$l1 = $name;
1476
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1477
+					break;
1478
+
1479
+					case 1:
1480
+						$l2 = $name;
1481
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1482
+					break;
1483
+
1484
+					case 2:
1485
+						$l3 = $name;
1486
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1487
+					break;
1488
+
1489
+					case 3:
1490
+						$l4 = $name;
1491
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1492
+					break;
1493
+				}
1494
+
1495
+				unset($this_val, $n);
1496
+			}
1497
+
1498
+			unset($last, $jv);
1499
+		}
1500
+
1501
+		return $vars;
1502
+	}
1503
+
1504
+	/**
1505
+	 * @param string $name
1506
+	 * @param string $l1
1507
+	 */
1508
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1509
+		if ( $name == '' ) {
1510
+			$vars[] = $val;
1511
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1512
+			$vars[ $l1 ] = $val;
1513
+		}
1514
+	}
1515 1515
 
1516 1516
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1517
-        $tooltips = array(
1518
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1519
-            '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' ),
1520
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1521
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1522
-            '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' ),
1523
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1524
-            '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() ) ),
1525
-        );
1526
-
1527
-        if ( ! isset( $tooltips[ $name ] ) ) {
1528
-            return;
1529
-        }
1530
-
1531
-        if ( 'open' == $class ) {
1532
-            echo ' frm_help"';
1533
-        } else {
1534
-            echo ' class="frm_help"';
1535
-        }
1536
-
1537
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1538
-
1539
-        if ( 'open' != $class ) {
1540
-            echo '"';
1541
-        }
1542
-    }
1517
+		$tooltips = array(
1518
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1519
+			'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' ),
1520
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1521
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1522
+			'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' ),
1523
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1524
+			'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() ) ),
1525
+		);
1526
+
1527
+		if ( ! isset( $tooltips[ $name ] ) ) {
1528
+			return;
1529
+		}
1530
+
1531
+		if ( 'open' == $class ) {
1532
+			echo ' frm_help"';
1533
+		} else {
1534
+			echo ' class="frm_help"';
1535
+		}
1536
+
1537
+		echo ' title="'. esc_attr( $tooltips[ $name ] );
1538
+
1539
+		if ( 'open' != $class ) {
1540
+			echo '"';
1541
+		}
1542
+	}
1543 1543
 
1544 1544
 	/**
1545 1545
 	 * Add the current_page class to that page in the form nav
@@ -1555,35 +1555,35 @@  discard block
 block discarded – undo
1555 1555
 		}
1556 1556
 	}
1557 1557
 
1558
-    /**
1559
-     * Prepare and json_encode post content
1560
-     *
1561
-     * @since 2.0
1562
-     *
1563
-     * @param array $post_content
1564
-     * @return string $post_content ( json encoded array )
1565
-     */
1566
-    public static function prepare_and_encode( $post_content ) {
1567
-        //Loop through array to strip slashes and add only the needed ones
1558
+	/**
1559
+	 * Prepare and json_encode post content
1560
+	 *
1561
+	 * @since 2.0
1562
+	 *
1563
+	 * @param array $post_content
1564
+	 * @return string $post_content ( json encoded array )
1565
+	 */
1566
+	public static function prepare_and_encode( $post_content ) {
1567
+		//Loop through array to strip slashes and add only the needed ones
1568 1568
 		foreach ( $post_content as $key => $val ) {
1569 1569
 			// Replace problematic characters (like &quot;)
1570 1570
 			$val = str_replace( '&quot;', '"', $val );
1571 1571
 
1572 1572
 			self::prepare_action_slashes( $val, $key, $post_content );
1573
-            unset( $key, $val );
1574
-        }
1573
+			unset( $key, $val );
1574
+		}
1575 1575
 
1576
-        // json_encode the array
1577
-        $post_content = json_encode( $post_content );
1576
+		// json_encode the array
1577
+		$post_content = json_encode( $post_content );
1578 1578
 
1579
-	    // add extra slashes for \r\n since WP strips them
1579
+		// add extra slashes for \r\n since WP strips them
1580 1580
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1581 1581
 
1582
-        // allow for &quot
1583
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1582
+		// allow for &quot
1583
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1584 1584
 
1585
-        return $post_content;
1586
-    }
1585
+		return $post_content;
1586
+	}
1587 1587
 
1588 1588
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1589 1589
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1651,64 +1651,64 @@  discard block
 block discarded – undo
1651 1651
 	}
1652 1652
 
1653 1653
 	public static function maybe_json_decode( $string ) {
1654
-        if ( is_array($string) ) {
1655
-            return $string;
1656
-        }
1654
+		if ( is_array($string) ) {
1655
+			return $string;
1656
+		}
1657 1657
 
1658
-        $new_string = json_decode($string, true);
1659
-        if ( function_exists('json_last_error') ) {
1658
+		$new_string = json_decode($string, true);
1659
+		if ( function_exists('json_last_error') ) {
1660 1660
 			// php 5.3+
1661
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1662
-                $string = $new_string;
1663
-            }
1664
-        } else if ( isset($new_string) ) {
1661
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1662
+				$string = $new_string;
1663
+			}
1664
+		} else if ( isset($new_string) ) {
1665 1665
 			// php < 5.3 fallback
1666
-            $string = $new_string;
1667
-        }
1668
-        return $string;
1669
-    }
1670
-
1671
-    /**
1672
-     * @since 1.07.10
1673
-     *
1674
-     * @param string $post_type The name of the post type that may need to be highlighted
1675
-     * @return echo The javascript to open and highlight the Formidable menu
1676
-     */
1666
+			$string = $new_string;
1667
+		}
1668
+		return $string;
1669
+	}
1670
+
1671
+	/**
1672
+	 * @since 1.07.10
1673
+	 *
1674
+	 * @param string $post_type The name of the post type that may need to be highlighted
1675
+	 * @return echo The javascript to open and highlight the Formidable menu
1676
+	 */
1677 1677
 	public static function maybe_highlight_menu( $post_type ) {
1678
-        global $post, $pagenow;
1678
+		global $post, $pagenow;
1679 1679
 
1680
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1681
-            return;
1682
-        }
1680
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1681
+			return;
1682
+		}
1683 1683
 
1684
-        if ( is_object($post) && $post->post_type != $post_type ) {
1685
-            return;
1686
-        }
1684
+		if ( is_object($post) && $post->post_type != $post_type ) {
1685
+			return;
1686
+		}
1687 1687
 
1688
-        self::load_admin_wide_js();
1689
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1690
-    }
1688
+		self::load_admin_wide_js();
1689
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1690
+	}
1691 1691
 
1692
-    /**
1693
-     * Load the JS file on non-Formidable pages in the admin area
1694
-     * @since 2.0
1695
-     */
1692
+	/**
1693
+	 * Load the JS file on non-Formidable pages in the admin area
1694
+	 * @since 2.0
1695
+	 */
1696 1696
 	public static function load_admin_wide_js( $load = true ) {
1697
-        $version = FrmAppHelper::plugin_version();
1697
+		$version = FrmAppHelper::plugin_version();
1698 1698
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1699 1699
 
1700
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1700
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1701 1701
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1702
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1702
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1703 1703
 			'url'          => FrmAppHelper::plugin_url(),
1704 1704
 			'loading'      => __( 'Loading&hellip;' ),
1705 1705
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1706
-        ) );
1706
+		) );
1707 1707
 
1708 1708
 		if ( $load ) {
1709 1709
 			wp_enqueue_script( 'formidable_admin_global' );
1710 1710
 		}
1711
-    }
1711
+	}
1712 1712
 
1713 1713
 	/**
1714 1714
 	 * @since 2.0.9
@@ -1717,9 +1717,9 @@  discard block
 block discarded – undo
1717 1717
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1718 1718
 	}
1719 1719
 
1720
-    /**
1721
-     * @param string $location
1722
-     */
1720
+	/**
1721
+	 * @param string $location
1722
+	 */
1723 1723
 	public static function localize_script( $location ) {
1724 1724
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1725 1725
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1769,81 +1769,81 @@  discard block
 block discarded – undo
1769 1769
 		}
1770 1770
 	}
1771 1771
 
1772
-    /**
1772
+	/**
1773 1773
 	 * echo the message on the plugins listing page
1774
-     * @since 1.07.10
1775
-     *
1776
-     * @param float $min_version The version the add-on requires
1777
-     */
1774
+	 * @since 1.07.10
1775
+	 *
1776
+	 * @param float $min_version The version the add-on requires
1777
+	 */
1778 1778
 	public static function min_version_notice( $min_version ) {
1779
-        $frm_version = self::plugin_version();
1779
+		$frm_version = self::plugin_version();
1780 1780
 
1781
-        // check if Formidable meets minimum requirements
1782
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1783
-            return;
1784
-        }
1781
+		// check if Formidable meets minimum requirements
1782
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1783
+			return;
1784
+		}
1785 1785
 
1786
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1786
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1787 1787
 		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">' .
1788
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1789
-        '</div></td></tr>';
1790
-    }
1791
-
1792
-    public static function locales( $type = 'date' ) {
1793
-        $locales = array(
1794
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1795
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1796
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1797
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1798
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1799
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1800
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1801
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1802
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1803
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1804
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1805
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1806
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1807
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1808
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1809
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1810
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1811
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1812
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1813
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1814
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1815
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1816
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1817
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1818
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1819
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1820
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1821
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1822
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1823
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1824
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1825
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1826
-        );
1827
-
1828
-        if ( $type == 'captcha' ) {
1829
-            // remove the languages unavailable for the captcha
1830
-            $unset = array(
1831
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1832
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1833
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1834
-            );
1835
-        } else {
1836
-            // remove the languages unavailable for the datepicker
1837
-            $unset = array(
1838
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1839
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1840
-                'es-419', 'tr',
1841
-            );
1842
-        }
1843
-
1844
-        $locales = array_diff_key($locales, array_flip($unset));
1845
-        $locales = apply_filters('frm_locales', $locales);
1846
-
1847
-        return $locales;
1848
-    }
1788
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1789
+		'</div></td></tr>';
1790
+	}
1791
+
1792
+	public static function locales( $type = 'date' ) {
1793
+		$locales = array(
1794
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1795
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1796
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1797
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1798
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1799
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1800
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1801
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1802
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1803
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1804
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1805
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1806
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1807
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1808
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1809
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1810
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1811
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1812
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1813
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1814
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1815
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1816
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1817
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1818
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1819
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1820
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1821
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1822
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1823
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1824
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1825
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1826
+		);
1827
+
1828
+		if ( $type == 'captcha' ) {
1829
+			// remove the languages unavailable for the captcha
1830
+			$unset = array(
1831
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1832
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1833
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1834
+			);
1835
+		} else {
1836
+			// remove the languages unavailable for the datepicker
1837
+			$unset = array(
1838
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1839
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1840
+				'es-419', 'tr',
1841
+			);
1842
+		}
1843
+
1844
+		$locales = array_diff_key($locales, array_flip($unset));
1845
+		$locales = apply_filters('frm_locales', $locales);
1846
+
1847
+		return $locales;
1848
+	}
1849 1849
 }
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   +314 added lines, -314 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,271 +217,271 @@  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',
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 374
 			'title_margin_top'  => '10px',
375 375
 			'title_margin_bottom' => '10px',
376
-            'form_desc_size'    => '14px',
377
-            'form_desc_color'   => '666666',
376
+			'form_desc_size'    => '14px',
377
+			'form_desc_color'   => '666666',
378 378
 			'form_desc_margin_top' => '10px',
379 379
 			'form_desc_margin_bottom' => '25px',
380 380
 
381
-            'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
382
-            'font_size'         => '14px',
383
-            'label_color'       => '444444',
384
-            'weight'            => 'bold',
385
-            'position'          => 'none',
386
-            'align'             => 'left',
387
-            'width'             => '150px',
388
-            'required_color'    => 'B94A48',
389
-            'required_weight'   => 'bold',
390
-            'label_padding'     => '0 0 3px 0',
391
-
392
-            'description_font_size' => '12px',
393
-            'description_color' => '666666',
394
-            'description_weight' => 'normal',
395
-            'description_style' => 'normal',
396
-            'description_align' => 'left',
397
-
398
-            'field_font_size'   => '14px',
399
-            'field_height' 		=> '32px',
400
-            'line_height'		=> 'normal',
401
-            'field_width'       => '100%',
402
-            'auto_width'        => false,
403
-            'field_pad'         => '6px 10px',
404
-            'field_margin'      => '20px',
381
+			'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
382
+			'font_size'         => '14px',
383
+			'label_color'       => '444444',
384
+			'weight'            => 'bold',
385
+			'position'          => 'none',
386
+			'align'             => 'left',
387
+			'width'             => '150px',
388
+			'required_color'    => 'B94A48',
389
+			'required_weight'   => 'bold',
390
+			'label_padding'     => '0 0 3px 0',
391
+
392
+			'description_font_size' => '12px',
393
+			'description_color' => '666666',
394
+			'description_weight' => 'normal',
395
+			'description_style' => 'normal',
396
+			'description_align' => 'left',
397
+
398
+			'field_font_size'   => '14px',
399
+			'field_height' 		=> '32px',
400
+			'line_height'		=> 'normal',
401
+			'field_width'       => '100%',
402
+			'auto_width'        => false,
403
+			'field_pad'         => '6px 10px',
404
+			'field_margin'      => '20px',
405 405
 			'field_weight' => 'normal',
406
-            'text_color'        => '555555',
407
-            //'border_color_hv'   => 'cccccc',
408
-            'border_color'      => 'cccccc',
409
-            'field_border_width' => '1px',
410
-            'field_border_style' => 'solid',
411
-
412
-            'bg_color'          => 'ffffff',
413
-            //'bg_color_hv'       => 'ffffff',
406
+			'text_color'        => '555555',
407
+			//'border_color_hv'   => 'cccccc',
408
+			'border_color'      => 'cccccc',
409
+			'field_border_width' => '1px',
410
+			'field_border_style' => 'solid',
411
+
412
+			'bg_color'          => 'ffffff',
413
+			//'bg_color_hv'       => 'ffffff',
414 414
 			'remove_box_shadow' => '',
415
-            'bg_color_active'   => 'ffffff',
415
+			'bg_color_active'   => 'ffffff',
416 416
 			'border_color_active' => '66afe9',
417 417
 			'remove_box_shadow_active' => '',
418
-            'text_color_error'  => '444444',
419
-            'bg_color_error'    => 'ffffff',
418
+			'text_color_error'  => '444444',
419
+			'bg_color_error'    => 'ffffff',
420 420
 			'border_color_error' => 'B94A48',
421 421
 			'border_width_error' => '1px',
422 422
 			'border_style_error' => 'solid',
423
-            'bg_color_disabled' => 'ffffff',
424
-            'border_color_disabled' => 'E5E5E5',
425
-            'text_color_disabled' => 'A1A1A1',
426
-
427
-            'radio_align'       => 'block',
428
-            'check_align'       => 'block',
429
-            'check_font_size'   => '13px',
430
-            'check_label_color' => '444444',
431
-            'check_weight'      => 'normal',
432
-
433
-            'section_font_size' => '18px',
434
-            'section_color'     => '444444',
435
-            'section_weight'    => 'bold',
436
-            'section_pad'       => '15px 0 3px 0',
437
-            'section_mar_top'   => '15px',
423
+			'bg_color_disabled' => 'ffffff',
424
+			'border_color_disabled' => 'E5E5E5',
425
+			'text_color_disabled' => 'A1A1A1',
426
+
427
+			'radio_align'       => 'block',
428
+			'check_align'       => 'block',
429
+			'check_font_size'   => '13px',
430
+			'check_label_color' => '444444',
431
+			'check_weight'      => 'normal',
432
+
433
+			'section_font_size' => '18px',
434
+			'section_color'     => '444444',
435
+			'section_weight'    => 'bold',
436
+			'section_pad'       => '15px 0 3px 0',
437
+			'section_mar_top'   => '15px',
438 438
 			'section_mar_bottom' => '12px',
439
-            'section_bg_color'  => '',
440
-            'section_border_color' => 'e8e8e8',
441
-            'section_border_width' => '2px',
442
-            'section_border_style' => 'solid',
443
-            'section_border_loc' => '-top',
444
-            'collapse_icon'     => '6',
445
-            'collapse_pos'      => 'after',
446
-            'repeat_icon'       => '1',
447
-
448
-            'submit_style'      => false,
449
-            'submit_font_size'  => '14px',
450
-            'submit_width'      => 'auto',
451
-            'submit_height'     => 'auto',
452
-            'submit_bg_color'   => 'ffffff',
453
-            'submit_border_color' => 'cccccc',
454
-            'submit_border_width' => '1px',
455
-            'submit_text_color' => '444444',
456
-            'submit_weight'     => 'normal',
457
-            'submit_border_radius' => '4px',
458
-            'submit_bg_img'     => '',
459
-            'submit_margin'     => '10px',
460
-            'submit_padding'    => '6px 11px',
461
-            'submit_shadow_color' => 'eeeeee',
462
-            'submit_hover_bg_color' => 'efefef',
463
-            'submit_hover_color' => '444444',
464
-            'submit_hover_border_color' => 'cccccc',
465
-            'submit_active_bg_color' => 'efefef',
466
-            'submit_active_color' => '444444',
467
-            'submit_active_border_color' => 'cccccc',
468
-
469
-            'border_radius'     => '4px',
470
-            'error_bg'          => 'F2DEDE',
471
-            'error_border'      => 'EBCCD1',
472
-            'error_text'        => 'B94A48',
473
-            'error_font_size'   => '14px',
474
-
475
-            'success_bg_color'  => 'DFF0D8',
476
-            'success_border_color' => 'D6E9C6',
477
-            'success_text_color' => '468847',
478
-            'success_font_size' => '14px',
479
-
480
-            'important_style'   => false,
481
-
482
-            'custom_css'        => '',
483
-        );
484
-    }
439
+			'section_bg_color'  => '',
440
+			'section_border_color' => 'e8e8e8',
441
+			'section_border_width' => '2px',
442
+			'section_border_style' => 'solid',
443
+			'section_border_loc' => '-top',
444
+			'collapse_icon'     => '6',
445
+			'collapse_pos'      => 'after',
446
+			'repeat_icon'       => '1',
447
+
448
+			'submit_style'      => false,
449
+			'submit_font_size'  => '14px',
450
+			'submit_width'      => 'auto',
451
+			'submit_height'     => 'auto',
452
+			'submit_bg_color'   => 'ffffff',
453
+			'submit_border_color' => 'cccccc',
454
+			'submit_border_width' => '1px',
455
+			'submit_text_color' => '444444',
456
+			'submit_weight'     => 'normal',
457
+			'submit_border_radius' => '4px',
458
+			'submit_bg_img'     => '',
459
+			'submit_margin'     => '10px',
460
+			'submit_padding'    => '6px 11px',
461
+			'submit_shadow_color' => 'eeeeee',
462
+			'submit_hover_bg_color' => 'efefef',
463
+			'submit_hover_color' => '444444',
464
+			'submit_hover_border_color' => 'cccccc',
465
+			'submit_active_bg_color' => 'efefef',
466
+			'submit_active_color' => '444444',
467
+			'submit_active_border_color' => 'cccccc',
468
+
469
+			'border_radius'     => '4px',
470
+			'error_bg'          => 'F2DEDE',
471
+			'error_border'      => 'EBCCD1',
472
+			'error_text'        => 'B94A48',
473
+			'error_font_size'   => '14px',
474
+
475
+			'success_bg_color'  => 'DFF0D8',
476
+			'success_border_color' => 'D6E9C6',
477
+			'success_text_color' => '468847',
478
+			'success_font_size' => '14px',
479
+
480
+			'important_style'   => false,
481
+
482
+			'custom_css'        => '',
483
+		);
484
+	}
485 485
 
486 486
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
487 487
 		return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 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,31 +100,31 @@  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';
104
-		update_option( 'frm_last_style_update', date('njGi') );
103
+        $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
104
+		update_option( 'frm_last_style_update', date( 'njGi' ) );
105 105
 
106
-        if ( ! is_file($filename) ) {
106
+        if ( ! is_file( $filename ) ) {
107 107
             return;
108 108
         }
109 109
 
110 110
         $defaults = $this->get_defaults();
111 111
         $uploads = wp_upload_dir();
112
-        $target_path = $uploads['basedir'] .'/formidable';
113
-        $needed_dirs = array( $target_path, $target_path .'/css' );
112
+        $target_path = $uploads['basedir'] . '/formidable';
113
+        $needed_dirs = array( $target_path, $target_path . '/css' );
114 114
         $dirs_exist = true;
115 115
 
116 116
         $saving = true;
117
-        $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
117
+        $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
118 118
 
119 119
         ob_start();
120 120
         $frm_style = $this;
121
-        include($filename);
121
+        include( $filename );
122 122
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
123 123
         ob_end_clean();
124 124
 
125 125
         $access_type = get_filesystem_method();
126 126
         if ( $access_type === 'direct' ) {
127
-        	$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
127
+        	$creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, array() );
128 128
 		} else {
129 129
 			$creds = $this->get_ftp_creds( $access_type );
130 130
 		}
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
             if ( $dirs_exist ) {
140 140
 	        	global $wp_filesystem;
141 141
 
142
-            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
143
-            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
142
+            	$chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
143
+            	$chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
144 144
 
145 145
                 // Create the directories if need be:
146 146
             	foreach ( $needed_dirs as $_dir ) {
@@ -150,33 +150,33 @@  discard block
 block discarded – undo
150 150
                     }
151 151
             	}
152 152
 
153
-                $index_path = $target_path .'/index.php';
153
+                $index_path = $target_path . '/index.php';
154 154
                 $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
155 155
 
156 156
                 // only write the file if the folders exist
157 157
                 if ( $dirs_exist ) {
158
-                    $css_file = $target_path .'/css/formidablepro.css';
158
+                    $css_file = $target_path . '/css/formidablepro.css';
159 159
                     $wp_filesystem->put_contents( $css_file, $css, $chmod_file );
160 160
                 }
161 161
             }
162 162
         }
163 163
 
164
-        update_option('frmpro_css', $css);
164
+        update_option( 'frmpro_css', $css );
165 165
 
166
-        delete_transient('frmpro_css');
167
-        set_transient('frmpro_css', $css);
166
+        delete_transient( 'frmpro_css' );
167
+        set_transient( 'frmpro_css', $css );
168 168
 	}
169 169
 
170 170
 	private function get_ftp_creds( $type ) {
171 171
 		$credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) );
172 172
 
173
-		$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname'];
174
-		$credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username'];
175
-		$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : '';
173
+		$credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname'];
174
+		$credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username'];
175
+		$credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : '';
176 176
 
177 177
 		// Check to see if we are setting the public/private keys for ssh
178
-		$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : '';
179
-		$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : '';
178
+		$credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : '';
179
+		$credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : '';
180 180
 
181 181
 		// Sanitize the hostname, Some people might pass in odd-data:
182 182
 		$credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	}
219 219
 
220 220
 	public function destroy( $id ) {
221
-        return wp_delete_post($id);
221
+        return wp_delete_post( $id );
222 222
     }
223 223
 
224 224
     public function get_one() {
@@ -232,19 +232,19 @@  discard block
 block discarded – undo
232 232
             return $style;
233 233
         }
234 234
 
235
-        $style = get_post($this->id);
235
+        $style = get_post( $this->id );
236 236
 
237 237
         if ( ! $style ) {
238 238
             return $style;
239 239
         }
240 240
 
241
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
241
+        $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
242 242
 
243 243
         $default_values = $this->get_defaults();
244 244
 
245 245
         // fill default values
246
-        $style->post_content = $this->override_defaults($style->post_content);
247
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
246
+        $style->post_content = $this->override_defaults( $style->post_content );
247
+        $style->post_content = wp_parse_args( $style->post_content, $default_values );
248 248
 
249 249
         return $style;
250 250
     }
@@ -258,21 +258,21 @@  discard block
 block discarded – undo
258 258
 			'order'       => $order,
259 259
         );
260 260
 
261
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
261
+        $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
262 262
 
263
-        if ( empty($temp_styles) ) {
263
+        if ( empty( $temp_styles ) ) {
264 264
             global $wpdb;
265 265
             // make sure there wasn't a conflict with the query
266
-            $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');
267
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
266
+            $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' );
267
+            $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
268 268
 
269
-            if ( empty($temp_styles) ) {
269
+            if ( empty( $temp_styles ) ) {
270 270
                 // create a new style if there are none
271 271
          		$new = $this->get_new();
272 272
          		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
273 273
          		$new->menu_order = 1;
274
-         		$new = $this->save( (array) $new);
275
-         		$this->update('default');
274
+         		$new = $this->save( (array) $new );
275
+         		$this->update( 'default' );
276 276
 
277 277
                 $post_atts['include'] = $new;
278 278
 
@@ -296,25 +296,25 @@  discard block
 block discarded – undo
296 296
                 }
297 297
             }
298 298
 
299
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
299
+            $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
300 300
 
301 301
             // fill default values
302
-            $style->post_content = $this->override_defaults($style->post_content);
303
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
302
+            $style->post_content = $this->override_defaults( $style->post_content );
303
+            $style->post_content = wp_parse_args( $style->post_content, $default_values );
304 304
 
305
-			$styles[ $style->ID ] = $style;
305
+			$styles[$style->ID] = $style;
306 306
         }
307 307
 
308 308
         if ( ! $default_style ) {
309
-            $default_style = reset($styles);
310
-			$styles[ $default_style->ID ]->menu_order = 1;
309
+            $default_style = reset( $styles );
310
+			$styles[$default_style->ID]->menu_order = 1;
311 311
         }
312 312
 
313 313
         return $styles;
314 314
     }
315 315
 
316 316
 	public function get_default_style( $styles = null ) {
317
-        if ( ! isset($styles) ) {
317
+        if ( ! isset( $styles ) ) {
318 318
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
319 319
         }
320 320
 
@@ -326,24 +326,24 @@  discard block
 block discarded – undo
326 326
     }
327 327
 
328 328
 	public function override_defaults( $settings ) {
329
-	    if ( ! is_array($settings) ) {
329
+	    if ( ! is_array( $settings ) ) {
330 330
 	        return $settings;
331 331
 	    }
332 332
 
333
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
333
+	    $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
334 334
 
335
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
335
+	    if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
336 336
 	        $settings['form_desc_size'] = $settings['description_font_size'];
337 337
 	        $settings['form_desc_color'] = $settings['description_color'];
338 338
 	        $settings['title_color'] = $settings['label_color'];
339 339
 	    }
340 340
 
341
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
341
+	    if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) {
342 342
 	        $settings['section_color'] = $settings['label_color'];
343 343
 	        $settings['section_border_color'] = $settings['border_color'];
344 344
 	    }
345 345
 
346
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
346
+	    if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) {
347 347
 	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
348 348
 	        $settings['submit_hover_color'] = $settings['submit_text_color'];
349 349
 	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
     }
486 486
 
487 487
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
488
-		return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
488
+		return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
489 489
 	}
490 490
 
491 491
 	public static function get_bold_options() {
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/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.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $wpdb, $per_page;
9
+		global $wpdb, $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12 12
 
13
-        $form_id = $this->params['form'];
14
-        if ( ! $form_id ) {
15
-            $this->items = array();
16
-    		$this->set_pagination_args( array(
17
-    			'total_items' => 0,
13
+		$form_id = $this->params['form'];
14
+		if ( ! $form_id ) {
15
+			$this->items = array();
16
+			$this->set_pagination_args( array(
17
+				'total_items' => 0,
18 18
 				'per_page' => $per_page,
19
-    		) );
20
-            return;
21
-        }
19
+			) );
20
+			return;
21
+		}
22 22
 
23 23
 		$default_orderby = 'id';
24 24
 		$default_order = 'DESC';
25 25
 
26
-	    $s_query = array( 'it.form_id' => $form_id );
26
+		$s_query = array( 'it.form_id' => $form_id );
27 27
 
28 28
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
29 29
 
30
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
-	    }
30
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
+		}
34 34
 
35
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
37
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
35
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
+		if ( strpos($orderby, 'meta') !== false ) {
37
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39
-        }
39
+		}
40 40
 
41 41
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
42 42
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
43 43
 
44
-        $page = $this->get_pagenum();
44
+		$page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47
-        $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
-        $total_items = FrmEntry::getRecordCount($s_query);
47
+		$this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
+		$total_items = FrmEntry::getRecordCount($s_query);
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function no_items() {
57
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
59
-            _e( 'No Entries Found', 'formidable' );
60
-            return;
61
-        }
62
-
63
-        $form_id = $form = $this->params['form'];
64
-        if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
66
-        }
67
-        $colspan = $this->get_column_count();
68
-
69
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
57
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
+		if ( ! empty($s) ) {
59
+			_e( 'No Entries Found', 'formidable' );
60
+			return;
61
+		}
62
+
63
+		$form_id = $form = $this->params['form'];
64
+		if ( $form_id ) {
65
+			$form = FrmForm::getOne($form_id);
66
+		}
67
+		$colspan = $this->get_column_count();
68
+
69
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
70 70
 	}
71 71
 
72 72
 	public function search_box( $text, $input_id ) {
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Gets the name of the primary column in the Entries screen
78
-	*
79
-	* @since 2.0.14
80
-	*
81
-	* @return string $primary_column
82
-	*/
77
+	 * Gets the name of the primary column in the Entries screen
78
+	 *
79
+	 * @since 2.0.14
80
+	 *
81
+	 * @return string $primary_column
82
+	 */
83 83
 	protected function get_primary_column_name() {
84 84
 		$columns = get_column_headers( $this->screen );
85 85
 		$hidden = get_hidden_columns( $this->screen );
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
106
-        $action_links = $this->row_actions( $actions );
106
+		$action_links = $this->row_actions( $actions );
107 107
 
108 108
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
109 109
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113 113
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
114
-        $action_col = false;
114
+		$action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117 117
 			$class = $column_name .' column-'. $column_name;
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 			if ( in_array( $column_name, $hidden ) ) {
124 124
 				$class .= ' frm_hidden';
125 125
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
126
-			    $action_col = $column_name;
127
-            }
126
+				$action_col = $column_name;
127
+			}
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130 130
 			unset($class);
131 131
 			$attributes .= ' data-colname="' . $column_display_name  . '"';
132 132
 
133
-            $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
133
+			$col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
134 134
 			$this->column_name = $col_name;
135 135
 
136 136
 			switch ( $col_name ) {
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
 				case 'ip':
141 141
 				case 'id':
142 142
 				case 'item_key':
143
-				    $val = $item->{$col_name};
144
-				    break;
143
+					$val = $item->{$col_name};
144
+					break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
-				    break;
147
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
+					break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
-			        break;
155
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
+					break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
159
-    				break;
158
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
159
+					break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
162
-				    break;
161
+					$val = FrmAppHelper::post_edit_link($item->post_id);
162
+					break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
165
-				    $val = $user->user_login;
166
-				    break;
164
+					$user = get_userdata($item->user_id);
165
+					$val = $user->user_login;
166
+					break;
167 167
 				default:
168 168
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
169 169
 					if ( $val === false ) {
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 
175 175
 			if ( isset( $val ) ) {
176
-			    $r .= "<td $attributes>";
176
+				$r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178 178
 					$edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180
-			        $r .= $action_links;
180
+					$r .= $action_links;
181 181
 				} else {
182
-			        $r .= $val;
183
-			    }
184
-			    $r .= '</td>';
182
+					$r .= $val;
183
+				}
184
+				$r .= '</td>';
185 185
 			}
186 186
 			unset($val);
187 187
 		}
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 		return $r;
191 191
 	}
192 192
 
193
-    /**
194
-     * @param string $view_link
195
-     */
196
-    private function get_actions( &$actions, $item, $view_link ) {
193
+	/**
194
+	 * @param string $view_link
195
+	 */
196
+	private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
200
-            $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
199
+		if ( current_user_can('frm_delete_entries') ) {
200
+			$delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202
-	    }
202
+		}
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
205
-    }
204
+		$actions = apply_filters('frm_row_actions', $actions, $item);
205
+	}
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
208 208
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 
26 26
 	    $s_query = array( 'it.form_id' => $form_id );
27 27
 
28
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
28
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
29 29
 
30 30
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31 31
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
32
+	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
33 33
 	    }
34 34
 
35 35
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
36
+        if ( strpos( $orderby, 'meta' ) !== false ) {
37 37
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39 39
         }
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
         $page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47
-        $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
-        $total_items = FrmEntry::getRecordCount($s_query);
47
+        $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
+        $total_items = FrmEntry::getRecordCount( $s_query );
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
58
+	    if ( ! empty( $s ) ) {
59 59
             _e( 'No Entries Found', 'formidable' );
60 60
             return;
61 61
         }
62 62
 
63 63
         $form_id = $form = $this->params['form'];
64 64
         if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
65
+            $form = FrmForm::getOne( $form_id );
66 66
         }
67 67
         $colspan = $this->get_column_count();
68 68
 
69
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
69
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
70 70
 	}
71 71
 
72 72
 	public function search_box( $text, $input_id ) {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	public function single_row( $item, $style = '' ) {
100 100
 		// Set up the hover actions for this user
101 101
 		$actions = array();
102
-		$view_link = '?page=formidable-entries&frm_action=show&id='. $item->id;
102
+		$view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id;
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
113
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
114 114
         $action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117
-			$class = $column_name .' column-'. $column_name;
117
+			$class = $column_name . ' column-' . $column_name;
118 118
 
119 119
 			if ( $column_name === $primary ) {
120 120
 				$class .= ' column-primary';
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
             }
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130
-			unset($class);
131
-			$attributes .= ' data-colname="' . $column_display_name  . '"';
130
+			unset( $class );
131
+			$attributes .= ' data-colname="' . $column_display_name . '"';
132 132
 
133
-            $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
133
+            $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
134 134
 			$this->column_name = $col_name;
135 135
 
136 136
 			switch ( $col_name ) {
@@ -144,24 +144,24 @@  discard block
 block discarded – undo
144 144
 				    break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
147
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
148 148
 				    break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
155
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
156 156
 			        break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
158
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
159 159
     				break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
161
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
162 162
 				    break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
164
+				    $user = get_userdata( $item->user_id );
165 165
 				    $val = $user->user_login;
166 166
 				    break;
167 167
 				default:
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			if ( isset( $val ) ) {
176 176
 			    $r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178
-					$edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id;
178
+					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180 180
 			        $r .= $action_links;
181 181
 				} else {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			    }
184 184
 			    $r .= '</td>';
185 185
 			}
186
-			unset($val);
186
+			unset( $val );
187 187
 		}
188 188
 		$r .= '</tr>';
189 189
 
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
      * @param string $view_link
195 195
      */
196 196
     private function get_actions( &$actions, $item, $view_link ) {
197
-		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>';
197
+		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
200
-            $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
199
+        if ( current_user_can( 'frm_delete_entries' ) ) {
200
+            $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202 202
 	    }
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
204
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
205 205
     }
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/helpers/FrmStylesHelper.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStylesHelper {
3 3
 
4
-    public static function jquery_themes() {
5
-        $themes = array(
6
-            'ui-lightness'  => 'UI Lightness',
7
-            'ui-darkness'   => 'UI Darkness',
8
-            'smoothness'    => 'Smoothness',
9
-            'start'         => 'Start',
10
-            'redmond'       => 'Redmond',
11
-            'sunny'         => 'Sunny',
12
-            'overcast'      => 'Overcast',
13
-            'le-frog'       => 'Le Frog',
14
-            'flick'         => 'Flick',
4
+	public static function jquery_themes() {
5
+		$themes = array(
6
+			'ui-lightness'  => 'UI Lightness',
7
+			'ui-darkness'   => 'UI Darkness',
8
+			'smoothness'    => 'Smoothness',
9
+			'start'         => 'Start',
10
+			'redmond'       => 'Redmond',
11
+			'sunny'         => 'Sunny',
12
+			'overcast'      => 'Overcast',
13
+			'le-frog'       => 'Le Frog',
14
+			'flick'         => 'Flick',
15 15
 			'pepper-grinder' => 'Pepper Grinder',
16
-            'eggplant'      => 'Eggplant',
17
-            'dark-hive'     => 'Dark Hive',
18
-            'cupertino'     => 'Cupertino',
19
-            'south-street'  => 'South Street',
20
-            'blitzer'       => 'Blitzer',
21
-            'humanity'      => 'Humanity',
22
-            'hot-sneaks'    => 'Hot Sneaks',
23
-            'excite-bike'   => 'Excite Bike',
24
-            'vader'         => 'Vader',
25
-            'dot-luv'       => 'Dot Luv',
26
-            'mint-choc'     => 'Mint Choc',
27
-            'black-tie'     => 'Black Tie',
28
-            'trontastic'    => 'Trontastic',
29
-            'swanky-purse'  => 'Swanky Purse',
30
-        );
31
-
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
33
-        return $themes;
34
-    }
16
+			'eggplant'      => 'Eggplant',
17
+			'dark-hive'     => 'Dark Hive',
18
+			'cupertino'     => 'Cupertino',
19
+			'south-street'  => 'South Street',
20
+			'blitzer'       => 'Blitzer',
21
+			'humanity'      => 'Humanity',
22
+			'hot-sneaks'    => 'Hot Sneaks',
23
+			'excite-bike'   => 'Excite Bike',
24
+			'vader'         => 'Vader',
25
+			'dot-luv'       => 'Dot Luv',
26
+			'mint-choc'     => 'Mint Choc',
27
+			'black-tie'     => 'Black Tie',
28
+			'trontastic'    => 'Trontastic',
29
+			'swanky-purse'  => 'Swanky Purse',
30
+		);
31
+
32
+		$themes = apply_filters('frm_jquery_themes', $themes);
33
+		return $themes;
34
+	}
35 35
 
36 36
 	public static function jquery_css_url( $theme_css ) {
37
-        if ( $theme_css == -1 ) {
38
-            return;
39
-        }
40
-
41
-        if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
-            $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
-            $css_file = $theme_css;
45
-        } else {
46
-            $uploads = self::get_upload_base();
47
-            $file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
49
-                $css_file = $uploads['baseurl'] . $file_path;
50
-            } else {
51
-                $css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css';
52
-            }
53
-        }
54
-
55
-        return $css_file;
56
-    }
57
-
58
-    public static function enqueue_jquery_css() {
37
+		if ( $theme_css == -1 ) {
38
+			return;
39
+		}
40
+
41
+		if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
+			$css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
+		} else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
+			$css_file = $theme_css;
45
+		} else {
46
+			$uploads = self::get_upload_base();
47
+			$file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css';
48
+			if ( file_exists($uploads['basedir'] . $file_path) ) {
49
+				$css_file = $uploads['baseurl'] . $file_path;
50
+			} else {
51
+				$css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css';
52
+			}
53
+		}
54
+
55
+		return $css_file;
56
+	}
57
+
58
+	public static function enqueue_jquery_css() {
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
-        if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
-        }
64
-    }
61
+		if ( $theme_css != -1 ) {
62
+			wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
+		}
64
+	}
65 65
 
66 66
 	public static function get_form_for_page() {
67 67
 		global $frm_vars;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		return $form_id;
78 78
 	}
79 79
 
80
-    public static function get_upload_base() {
81
-        $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
-        }
80
+	public static function get_upload_base() {
81
+		$uploads = wp_upload_dir();
82
+		if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
+			$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
+		}
85 85
 
86
-        return $uploads;
87
-    }
86
+		return $uploads;
87
+	}
88 88
 
89 89
 	public static function style_menu( $active = '' ) {
90 90
 ?>
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97
-    }
97
+	}
98 98
 
99
-    public static function minus_icons() {
100
-        return array(
99
+	public static function minus_icons() {
100
+		return array(
101 101
 			0 => array( '-' => '62e', '+' => '62f' ),
102 102
 			1 => array( '-' => '600', '+' => '602' ),
103 103
 			2 => array( '-' => '604', '+' => '603' ),
104 104
 			3 => array( '-' => '633', '+' => '632' ),
105 105
 			4 => array( '-' => '613', '+' => '60f' ),
106
-        );
107
-    }
106
+		);
107
+	}
108 108
 
109
-    public static function arrow_icons() {
110
-        $minus_icons = self::minus_icons();
109
+	public static function arrow_icons() {
110
+		$minus_icons = self::minus_icons();
111 111
 
112
-        return array(
112
+		return array(
113 113
 			6 => array( '-' => '62d', '+' => '62a' ),
114 114
 			0 => array( '-' => '60d', '+' => '609' ),
115 115
 			1 => array( '-' => '60e', '+' => '60c' ),
@@ -117,44 +117,44 @@  discard block
 block discarded – undo
117 117
 			3 => array( '-' => '62b', '+' => '628' ),
118 118
 			4 => array( '-' => '62c', '+' => '629' ),
119 119
 			5 => array( '-' => '635', '+' => '634' ),
120
-            'p0' => $minus_icons[0],
121
-            'p1' => $minus_icons[1],
122
-            'p2' => $minus_icons[2],
123
-            'p3' => $minus_icons[3],
124
-            'p4' => $minus_icons[4],
125
-        );
126
-    }
127
-
128
-    /**
129
-     * @since 2.0
130
-     * @return The class for this icon
131
-     */
120
+			'p0' => $minus_icons[0],
121
+			'p1' => $minus_icons[1],
122
+			'p2' => $minus_icons[2],
123
+			'p3' => $minus_icons[3],
124
+			'p4' => $minus_icons[4],
125
+		);
126
+	}
127
+
128
+	/**
129
+	 * @since 2.0
130
+	 * @return The class for this icon
131
+	 */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
134
-            //frm_arrowup6_icon
133
+		if ( 'arrow' == $type && is_numeric($key) ) {
134
+			//frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136 136
 			$class = 'frm_arrow' . $arrow[ $icon ];
137
-        } else {
138
-            //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
137
+		} else {
138
+			//frm_minus1_icon
139
+			$key = str_replace('p', '', $key);
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141 141
 			$class = 'frm_' . $plus[ $icon ];
142
-        }
142
+		}
143 143
 
144
-        if ( $key ) {
145
-            $class .= $key;
146
-        }
147
-        $class .= '_icon';
144
+		if ( $key ) {
145
+			$class .= $key;
146
+		}
147
+		$class .= '_icon';
148 148
 
149
-        return $class;
150
-    }
149
+		return $class;
150
+	}
151 151
 
152 152
 	public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
153 153
 		$function_name = $type . '_icons';
154 154
 		$icons = self::$function_name();
155 155
 		unset( $function_name );
156 156
 
157
-        $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
157
+		$name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159 159
     	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
             </ul>
188 188
         </div>
189 189
 <?php
190
-    }
190
+	}
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
194
-
195
-        if ( strlen($hex) == 3 ) {
196
-            $r = hexdec( substr($hex,0,1).substr($hex,0,1) );
197
-            $g = hexdec( substr($hex,1,1).substr($hex,1,1) );
198
-            $b = hexdec( substr($hex,2,1).substr($hex,2,1) );
199
-        } else {
200
-            $r = hexdec( substr($hex,0,2) );
201
-            $g = hexdec( substr($hex,2,2) );
202
-            $b = hexdec( substr($hex,4,2) );
203
-        }
193
+		$hex = str_replace('#', '', $hex);
194
+
195
+		if ( strlen($hex) == 3 ) {
196
+			$r = hexdec( substr($hex,0,1).substr($hex,0,1) );
197
+			$g = hexdec( substr($hex,1,1).substr($hex,1,1) );
198
+			$b = hexdec( substr($hex,2,1).substr($hex,2,1) );
199
+		} else {
200
+			$r = hexdec( substr($hex,0,2) );
201
+			$g = hexdec( substr($hex,2,2) );
202
+			$b = hexdec( substr($hex,4,2) );
203
+		}
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
206
-        //return $rgb; // returns an array with the rgb values
207
-    }
205
+		return implode(',', $rgb); // returns the rgb values separated by commas
206
+		//return $rgb; // returns an array with the rgb values
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             'swanky-purse'  => 'Swanky Purse',
30 30
         );
31 31
 
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
32
+        $themes = apply_filters( 'frm_jquery_themes', $themes );
33 33
         return $themes;
34 34
     }
35 35
 
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 
41 41
         if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42 42
             $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
43
+        } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) {
44 44
             $css_file = $theme_css;
45 45
         } else {
46 46
             $uploads = self::get_upload_base();
47
-            $file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
47
+            $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
+            if ( file_exists( $uploads['basedir'] . $file_path ) ) {
49 49
                 $css_file = $uploads['baseurl'] . $file_path;
50 50
             } else {
51
-                $css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css';
51
+                $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
52 52
             }
53 53
         }
54 54
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61 61
         if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
62
+            wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
63 63
         }
64 64
     }
65 65
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
     public static function get_upload_base() {
81 81
         $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
82
+        if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
83
+            $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
84 84
         }
85 85
 
86 86
         return $uploads;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         <h2 class="nav-tab-wrapper">
92 92
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a>
93 93
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a>
94
-			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
94
+			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97 97
     }
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
      * @return The class for this icon
131 131
      */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
133
+        if ( 'arrow' == $type && is_numeric( $key ) ) {
134 134
             //frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136
-			$class = 'frm_arrow' . $arrow[ $icon ];
136
+			$class = 'frm_arrow' . $arrow[$icon];
137 137
         } else {
138 138
             //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
139
+            $key = str_replace( 'p', '', $key );
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141
-			$class = 'frm_' . $plus[ $icon ];
141
+			$class = 'frm_' . $plus[$icon];
142 142
         }
143 143
 
144 144
         if ( $key ) {
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
 
157 157
         $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159
-    	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
159
+    	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
161
-			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
162
-                <?php echo '&#xe'. $icon['+'] .'; &#xe'. $icon['-'] .';'; ?>
161
+			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
162
+                <?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
163 163
             </option>
164 164
             <?php } ?>
165 165
     	</select>
166 166
 
167 167
         <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
168 168
             <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
169
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
170
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
169
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
170
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
171 171
                 <b class="caret"></b>
172 172
             </button>
173 173
             <ul class="multiselect-container frm-dropdown-menu">
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+        $hex = str_replace( '#', '', $hex );
194 194
 
195
-        if ( strlen($hex) == 3 ) {
196
-            $r = hexdec( substr($hex,0,1).substr($hex,0,1) );
197
-            $g = hexdec( substr($hex,1,1).substr($hex,1,1) );
198
-            $b = hexdec( substr($hex,2,1).substr($hex,2,1) );
195
+        if ( strlen( $hex ) == 3 ) {
196
+            $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197
+            $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198
+            $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
199 199
         } else {
200
-            $r = hexdec( substr($hex,0,2) );
201
-            $g = hexdec( substr($hex,2,2) );
202
-            $b = hexdec( substr($hex,4,2) );
200
+            $r = hexdec( substr( $hex, 0, 2 ) );
201
+            $g = hexdec( substr( $hex, 2, 2 ) );
202
+            $b = hexdec( substr( $hex, 4, 2 ) );
203 203
         }
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
205
+        return implode( ',', $rgb ); // returns the rgb values separated by commas
206 206
         //return $rgb; // returns an array with the rgb values
207 207
     }
208 208
 }
Please login to merge, or discard this patch.