Completed
Push — master ( a21a14...567d89 )
by Stephanie
03:02
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +559 added lines, -559 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public static $plug_version = '3.01.03';
15 15
 
16
-    /**
17
-     * @since 1.07.02
18
-     *
19
-     * @param none
20
-     * @return string The version of this plugin
21
-     */
22
-    public static function plugin_version() {
23
-        return self::$plug_version;
24
-    }
16
+	/**
17
+	 * @since 1.07.02
18
+	 *
19
+	 * @param none
20
+	 * @return string The version of this plugin
21
+	 */
22
+	public static function plugin_version() {
23
+		return self::$plug_version;
24
+	}
25 25
 
26 26
 	public static function plugin_folder() {
27 27
 		return basename( self::plugin_path() );
@@ -31,29 +31,29 @@  discard block
 block discarded – undo
31 31
 		return dirname( dirname( dirname( __FILE__ ) ) );
32 32
 	}
33 33
 
34
-    public static function plugin_url() {
35
-        //prevously FRM_URL constant
34
+	public static function plugin_url() {
35
+		//prevously FRM_URL constant
36 36
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
37
-    }
37
+	}
38 38
 
39 39
 	public static function relative_plugin_url() {
40 40
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
41 41
 	}
42 42
 
43
-    /**
44
-     * @return string Site URL
45
-     */
46
-    public static function site_url() {
47
-        return site_url();
48
-    }
49
-
50
-    /**
51
-     * Get the name of this site
52
-     * Used for [sitename] shortcode
53
-     *
54
-     * @since 2.0
55
-     * @return string
56
-     */
43
+	/**
44
+	 * @return string Site URL
45
+	 */
46
+	public static function site_url() {
47
+		return site_url();
48
+	}
49
+
50
+	/**
51
+	 * Get the name of this site
52
+	 * Used for [sitename] shortcode
53
+	 *
54
+	 * @since 2.0
55
+	 * @return string
56
+	 */
57 57
 	public static function site_name() {
58 58
 		return get_option( 'blogname' );
59 59
 	}
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 		return absint( apply_filters( 'frm_affiliate_id', 0 ) );
72 72
 	}
73 73
 
74
-    /**
75
-     * Get the Formidable settings
76
-     *
77
-     * @since 2.0
78
-     *
79
-     * @param None
80
-     * @return FrmSettings $frm_setings
81
-     */
74
+	/**
75
+	 * Get the Formidable settings
76
+	 *
77
+	 * @since 2.0
78
+	 *
79
+	 * @param None
80
+	 * @return FrmSettings $frm_setings
81
+	 */
82 82
 	public static function get_settings() {
83 83
 		global $frm_settings;
84 84
 		if ( empty( $frm_settings ) ) {
@@ -119,50 +119,50 @@  discard block
 block discarded – undo
119 119
 		return $is_formidable;
120 120
 	}
121 121
 
122
-    /**
123
-     * Check for certain page in Formidable settings
124
-     *
125
-     * @since 2.0
126
-     *
127
-     * @param string $page The name of the page to check
128
-     * @return boolean
129
-     */
122
+	/**
123
+	 * Check for certain page in Formidable settings
124
+	 *
125
+	 * @since 2.0
126
+	 *
127
+	 * @param string $page The name of the page to check
128
+	 * @return boolean
129
+	 */
130 130
 	public static function is_admin_page( $page = 'formidable' ) {
131
-        global $pagenow;
131
+		global $pagenow;
132 132
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
133
-        if ( $pagenow ) {
133
+		if ( $pagenow ) {
134 134
 			// allow this to be true during ajax load i.e. ajax form builder loading
135 135
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
136
-        }
136
+		}
137 137
 
138 138
 		return is_admin() && $get_page == $page;
139
-    }
140
-
141
-    /**
142
-     * Check for the form preview page
143
-     *
144
-     * @since 2.0
145
-     *
146
-     * @param None
147
-     * @return boolean
148
-     */
149
-    public static function is_preview_page() {
150
-        global $pagenow;
139
+	}
140
+
141
+	/**
142
+	 * Check for the form preview page
143
+	 *
144
+	 * @since 2.0
145
+	 *
146
+	 * @param None
147
+	 * @return boolean
148
+	 */
149
+	public static function is_preview_page() {
150
+		global $pagenow;
151 151
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
152 152
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
153
-    }
154
-
155
-    /**
156
-     * Check for ajax except the form preview page
157
-     *
158
-     * @since 2.0
159
-     *
160
-     * @param None
161
-     * @return boolean
162
-     */
163
-    public static function doing_ajax() {
164
-        return self::wp_doing_ajax() && ! self::is_preview_page();
165
-    }
153
+	}
154
+
155
+	/**
156
+	 * Check for ajax except the form preview page
157
+	 *
158
+	 * @since 2.0
159
+	 *
160
+	 * @param None
161
+	 * @return boolean
162
+	 */
163
+	public static function doing_ajax() {
164
+		return self::wp_doing_ajax() && ! self::is_preview_page();
165
+	}
166 166
 
167 167
 	public static function js_suffix() {
168 168
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -189,81 +189,81 @@  discard block
 block discarded – undo
189 189
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
190 190
 	}
191 191
 
192
-    /**
193
-     * Check if on an admin page
194
-     *
195
-     * @since 2.0
196
-     *
197
-     * @param None
198
-     * @return boolean
199
-     */
200
-    public static function is_admin() {
201
-        return is_admin() && ! self::wp_doing_ajax();
202
-    }
203
-
204
-    /**
205
-     * Check if value contains blank value or empty array
206
-     *
207
-     * @since 2.0
208
-     * @param mixed $value - value to check
192
+	/**
193
+	 * Check if on an admin page
194
+	 *
195
+	 * @since 2.0
196
+	 *
197
+	 * @param None
198
+	 * @return boolean
199
+	 */
200
+	public static function is_admin() {
201
+		return is_admin() && ! self::wp_doing_ajax();
202
+	}
203
+
204
+	/**
205
+	 * Check if value contains blank value or empty array
206
+	 *
207
+	 * @since 2.0
208
+	 * @param mixed $value - value to check
209 209
 	 * @param string
210
-     * @return boolean
211
-     */
212
-    public static function is_empty_value( $value, $empty = '' ) {
213
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
-    }
215
-
216
-    public static function is_not_empty_value( $value, $empty = '' ) {
217
-        return ! self::is_empty_value( $value, $empty );
218
-    }
219
-
220
-    /**
221
-     * Get any value from the $_SERVER
222
-     *
223
-     * @since 2.0
224
-     * @param string $value
225
-     * @return string
226
-     */
210
+	 * @return boolean
211
+	 */
212
+	public static function is_empty_value( $value, $empty = '' ) {
213
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
+	}
215
+
216
+	public static function is_not_empty_value( $value, $empty = '' ) {
217
+		return ! self::is_empty_value( $value, $empty );
218
+	}
219
+
220
+	/**
221
+	 * Get any value from the $_SERVER
222
+	 *
223
+	 * @since 2.0
224
+	 * @param string $value
225
+	 * @return string
226
+	 */
227 227
 	public static function get_server_value( $value ) {
228
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
-    }
230
-
231
-    /**
232
-     * Check for the IP address in several places
233
-     * Used by [ip] shortcode
234
-     *
235
-     * @return string The IP address of the current user
236
-     */
237
-    public static function get_ip_address() {
228
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
+	}
230
+
231
+	/**
232
+	 * Check for the IP address in several places
233
+	 * Used by [ip] shortcode
234
+	 *
235
+	 * @return string The IP address of the current user
236
+	 */
237
+	public static function get_ip_address() {
238 238
 		$ip = '';
239 239
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
240
-            if ( ! isset( $_SERVER[ $key ] ) ) {
241
-                continue;
242
-            }
240
+			if ( ! isset( $_SERVER[ $key ] ) ) {
241
+				continue;
242
+			}
243 243
 
244
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
244
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245 245
 				$ip = trim( $ip ); // just to be safe
246 246
 
247 247
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
248
-                    return sanitize_text_field( $ip );
249
-                }
250
-            }
251
-        }
248
+					return sanitize_text_field( $ip );
249
+				}
250
+			}
251
+		}
252 252
 
253 253
 		return sanitize_text_field( $ip );
254
-    }
254
+	}
255 255
 
256
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
256
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257 257
 		if ( strpos( $param, '[' ) ) {
258 258
 			$params = explode( '[', $param );
259
-            $param = $params[0];
260
-        }
259
+			$param = $params[0];
260
+		}
261 261
 
262 262
 		if ( $src == 'get' ) {
263
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
-            }
263
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
+			}
267 267
 			self::sanitize_value( $sanitize, $value );
268 268
 		} else {
269 269
 			$value = self::get_simple_request( array(
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 			}
286 286
 		}
287 287
 
288
-        return $value;
289
-    }
288
+		return $value;
289
+	}
290 290
 
291 291
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
292 292
 		return self::get_simple_request( array(
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 	}
351 351
 
352 352
 	/**
353
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
-	*
355
-	* @since 2.0.8
356
-	* @param string $value
357
-	* @return string $value
358
-	*/
353
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
+	 *
355
+	 * @since 2.0.8
356
+	 * @param string $value
357
+	 * @return string $value
358
+	 */
359 359
 	public static function preserve_backslashes( $value ) {
360 360
 		// If backslashes have already been added, don't add them again
361 361
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 	}
379 379
 
380
-    public static function sanitize_request( $sanitize_method, &$values ) {
381
-        $temp_values = $values;
382
-        foreach ( $temp_values as $k => $val ) {
383
-            if ( isset( $sanitize_method[ $k ] ) ) {
380
+	public static function sanitize_request( $sanitize_method, &$values ) {
381
+		$temp_values = $values;
382
+		foreach ( $temp_values as $k => $val ) {
383
+			if ( isset( $sanitize_method[ $k ] ) ) {
384 384
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
385
-            }
386
-        }
387
-    }
385
+			}
386
+		}
387
+	}
388 388
 
389 389
 	/**
390 390
 	 * @deprecated 3.01
@@ -514,39 +514,39 @@  discard block
 block discarded – undo
514 514
 		);
515 515
 	}
516 516
 
517
-    /**
518
-     * Used when switching the action for a bulk action
519
-     * @since 2.0
520
-     */
517
+	/**
518
+	 * Used when switching the action for a bulk action
519
+	 * @since 2.0
520
+	 */
521 521
 	public static function remove_get_action() {
522 522
 		if ( ! isset( $_GET ) ) {
523 523
 			return;
524 524
 		}
525 525
 
526
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
527
-        if ( ! empty( $new_action ) ) {
526
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
527
+		if ( ! empty( $new_action ) ) {
528 528
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
529
-        }
530
-    }
529
+		}
530
+	}
531 531
 
532
-    /**
533
-     * Check the WP query for a parameter
534
-     *
535
-     * @since 2.0
536
-     * @return string|array
537
-     */
538
-    public static function get_query_var( $value, $param ) {
539
-        if ( $value != '' ) {
540
-            return $value;
541
-        }
532
+	/**
533
+	 * Check the WP query for a parameter
534
+	 *
535
+	 * @since 2.0
536
+	 * @return string|array
537
+	 */
538
+	public static function get_query_var( $value, $param ) {
539
+		if ( $value != '' ) {
540
+			return $value;
541
+		}
542 542
 
543
-        global $wp_query;
544
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
545
-            $value = $wp_query->query_vars[ $param ];
546
-        }
543
+		global $wp_query;
544
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
545
+			$value = $wp_query->query_vars[ $param ];
546
+		}
547 547
 
548
-        return $value;
549
-    }
548
+		return $value;
549
+	}
550 550
 
551 551
 	/**
552 552
 	 * @since 3.0
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
 		}
569 569
 	}
570 570
 
571
-    /**
572
-     * @param string $type
573
-     */
574
-    public static function trigger_hook_load( $type, $object = null ) {
575
-        // only load the form hooks once
571
+	/**
572
+	 * @param string $type
573
+	 */
574
+	public static function trigger_hook_load( $type, $object = null ) {
575
+		// only load the form hooks once
576 576
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
577
-        if ( ! $hooks_loaded ) {
577
+		if ( ! $hooks_loaded ) {
578 578
 			do_action( 'frm_load_' . $type . '_hooks' );
579
-        }
580
-    }
579
+		}
580
+	}
581 581
 
582 582
 	/**
583 583
 	 * Save all front-end js scripts into a single file
@@ -599,29 +599,29 @@  discard block
 block discarded – undo
599 599
 		$new_file->combine_files( $files );
600 600
 	}
601 601
 
602
-    /**
603
-     * Check a value from a shortcode to see if true or false.
604
-     * True when value is 1, true, 'true', 'yes'
605
-     *
606
-     * @since 1.07.10
607
-     *
608
-     * @param string $value The value to compare
609
-     * @return boolean True or False
610
-     */
602
+	/**
603
+	 * Check a value from a shortcode to see if true or false.
604
+	 * True when value is 1, true, 'true', 'yes'
605
+	 *
606
+	 * @since 1.07.10
607
+	 *
608
+	 * @param string $value The value to compare
609
+	 * @return boolean True or False
610
+	 */
611 611
 	public static function is_true( $value ) {
612
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
613
-    }
612
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
613
+	}
614 614
 
615
-    /**
616
-     * Used to filter shortcode in text widgets
615
+	/**
616
+	 * Used to filter shortcode in text widgets
617 617
 	 *
618 618
 	 * @deprecated 2.5.4
619 619
 	 * @codeCoverageIgnore
620
-     */
621
-    public static function widget_text_filter_callback( $matches ) {
620
+	 */
621
+	public static function widget_text_filter_callback( $matches ) {
622 622
 		_deprecated_function( __METHOD__, '2.5.4' );
623
-        return do_shortcode( $matches[0] );
624
-    }
623
+		return do_shortcode( $matches[0] );
624
+	}
625 625
 
626 626
 	public static function get_pages() {
627 627
 		return get_posts( array(
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
 		) );
634 634
 	}
635 635
 
636
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
637
-        $pages = self::get_pages();
636
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
637
+		$pages = self::get_pages();
638 638
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
639
-    ?>
639
+	?>
640 640
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
641 641
             <option value=""> </option>
642 642
             <?php foreach ( $pages as $page ) { ?>
@@ -646,16 +646,16 @@  discard block
 block discarded – undo
646 646
             <?php } ?>
647 647
         </select>
648 648
     <?php
649
-    }
649
+	}
650 650
 
651 651
 	public static function post_edit_link( $post_id ) {
652 652
 		$post = get_post( $post_id );
653
-        if ( $post ) {
653
+		if ( $post ) {
654 654
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
655 655
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
656
-        }
657
-        return '';
658
-    }
656
+		}
657
+		return '';
658
+	}
659 659
 
660 660
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
661 661
 		?>
@@ -666,73 +666,73 @@  discard block
 block discarded – undo
666 666
 	}
667 667
 
668 668
 	public static function roles_options( $capability ) {
669
-        global $frm_vars;
669
+		global $frm_vars;
670 670
 		if ( isset( $frm_vars['editable_roles'] ) ) {
671
-            $editable_roles = $frm_vars['editable_roles'];
672
-        } else {
673
-            $editable_roles = get_editable_roles();
674
-            $frm_vars['editable_roles'] = $editable_roles;
675
-        }
671
+			$editable_roles = $frm_vars['editable_roles'];
672
+		} else {
673
+			$editable_roles = get_editable_roles();
674
+			$frm_vars['editable_roles'] = $editable_roles;
675
+		}
676 676
 
677
-        foreach ( $editable_roles as $role => $details ) {
677
+		foreach ( $editable_roles as $role => $details ) {
678 678
 			$name = translate_user_role( $details['name'] );
679 679
 			?>
680 680
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
681 681
 <?php
682 682
 			unset( $role, $details );
683
-        }
684
-    }
683
+		}
684
+	}
685 685
 
686 686
 	public static function frm_capabilities( $type = 'auto' ) {
687
-        $cap = array(
688
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
689
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
690
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
691
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
692
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
693
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
694
-        );
687
+		$cap = array(
688
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
689
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
690
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
691
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
692
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
693
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
694
+		);
695 695
 
696 696
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
697
-            return $cap;
698
-        }
697
+			return $cap;
698
+		}
699 699
 
700
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
701
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
702
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
703
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
700
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
701
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
702
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
703
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
704 704
 
705
-        return $cap;
706
-    }
705
+		return $cap;
706
+	}
707 707
 
708 708
 	public static function user_has_permission( $needed_role ) {
709
-        if ( $needed_role == '-1' ) {
710
-            return false;
709
+		if ( $needed_role == '-1' ) {
710
+			return false;
711 711
 		}
712 712
 
713
-        // $needed_role will be equal to blank if "Logged-in users" is selected
714
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
715
-            return true;
716
-        }
713
+		// $needed_role will be equal to blank if "Logged-in users" is selected
714
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
715
+			return true;
716
+		}
717 717
 
718
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
719
-        foreach ( $roles as $role ) {
718
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
719
+		foreach ( $roles as $role ) {
720 720
 			if ( current_user_can( $role ) ) {
721
-        		return true;
721
+				return true;
722 722
 			}
723
-        	if ( $role == $needed_role ) {
724
-        		break;
723
+			if ( $role == $needed_role ) {
724
+				break;
725 725
 			}
726
-        }
727
-        return false;
728
-    }
729
-
730
-    /**
731
-     * Make sure administrators can see Formidable menu
732
-     *
733
-     * @since 2.0
734
-     */
735
-    public static function maybe_add_permissions() {
726
+		}
727
+		return false;
728
+	}
729
+
730
+	/**
731
+	 * Make sure administrators can see Formidable menu
732
+	 *
733
+	 * @since 2.0
734
+	 */
735
+	public static function maybe_add_permissions() {
736 736
 		self::force_capability( 'frm_view_entries' );
737 737
 
738 738
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
 
742 742
 		$user_id = get_current_user_id();
743 743
 		$user = new WP_User( $user_id );
744
-        $frm_roles = self::frm_capabilities();
745
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
744
+		$frm_roles = self::frm_capabilities();
745
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
746 746
 			$user->add_cap( $frm_role );
747 747
 			unset( $frm_role, $frm_role_description );
748
-        }
749
-    }
748
+		}
749
+	}
750 750
 
751 751
 	/**
752 752
 	 * Make sure admins have permission to see the menu items
@@ -762,28 +762,28 @@  discard block
 block discarded – undo
762 762
 		}
763 763
 	}
764 764
 
765
-    /**
766
-     * Check if the user has permision for action.
767
-     * Return permission message and stop the action if no permission
768
-     * @since 2.0
769
-     * @param string $permission
770
-     */
765
+	/**
766
+	 * Check if the user has permision for action.
767
+	 * Return permission message and stop the action if no permission
768
+	 * @since 2.0
769
+	 * @param string $permission
770
+	 */
771 771
 	public static function permission_check( $permission, $show_message = 'show' ) {
772 772
 		$permission_error = self::permission_nonce_error( $permission );
773
-        if ( $permission_error !== false ) {
774
-            if ( 'hide' == $show_message ) {
775
-                $permission_error = '';
776
-            }
773
+		if ( $permission_error !== false ) {
774
+			if ( 'hide' == $show_message ) {
775
+				$permission_error = '';
776
+			}
777 777
 			wp_die( esc_html( $permission_error ) );
778
-        }
779
-    }
780
-
781
-    /**
782
-     * Check user permission and nonce
783
-     * @since 2.0
784
-     * @param string $permission
785
-     * @return false|string The permission message or false if allowed
786
-     */
778
+		}
779
+	}
780
+
781
+	/**
782
+	 * Check user permission and nonce
783
+	 * @since 2.0
784
+	 * @param string $permission
785
+	 * @return false|string The permission message or false if allowed
786
+	 */
787 787
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
788 788
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
789 789
 			$frm_settings = self::get_settings();
@@ -792,22 +792,22 @@  discard block
 block discarded – undo
792 792
 
793 793
 		$error = false;
794 794
 		if ( empty( $nonce_name ) ) {
795
-            return $error;
796
-        }
795
+			return $error;
796
+		}
797 797
 
798
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
799
-            $frm_settings = self::get_settings();
800
-            $error = $frm_settings->admin_permission;
801
-        }
798
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
799
+			$frm_settings = self::get_settings();
800
+			$error = $frm_settings->admin_permission;
801
+		}
802 802
 
803
-        return $error;
804
-    }
803
+		return $error;
804
+	}
805 805
 
806
-    public static function checked( $values, $current ) {
806
+	public static function checked( $values, $current ) {
807 807
 		if ( self::check_selected( $values, $current ) ) {
808
-            echo ' checked="checked"';
808
+			echo ' checked="checked"';
809 809
 		}
810
-    }
810
+	}
811 811
 
812 812
 	public static function check_selected( $values, $current ) {
813 813
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -845,24 +845,24 @@  discard block
 block discarded – undo
845 845
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
846 846
 	}
847 847
 
848
-    /**
849
-     * Flatten a multi-dimensional array
850
-     */
848
+	/**
849
+	 * Flatten a multi-dimensional array
850
+	 */
851 851
 	public static function array_flatten( $array, $keys = 'keep' ) {
852
-        $return = array();
853
-        foreach ( $array as $key => $value ) {
852
+		$return = array();
853
+		foreach ( $array as $key => $value ) {
854 854
 			if ( is_array( $value ) ) {
855 855
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
856
-            } else {
856
+			} else {
857 857
 				if ( $keys == 'keep' ) {
858 858
 					$return[ $key ] = $value;
859 859
 				} else {
860 860
 					$return[] = $value;
861 861
 				}
862
-            }
863
-        }
864
-        return $return;
865
-    }
862
+			}
863
+		}
864
+		return $return;
865
+	}
866 866
 
867 867
 	public static function esc_textarea( $text, $is_rich_text = false ) {
868 868
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -873,10 +873,10 @@  discard block
 block discarded – undo
873 873
 		return apply_filters( 'esc_textarea', $safe_text, $text );
874 874
 	}
875 875
 
876
-    /**
877
-     * Add auto paragraphs to text areas
878
-     * @since 2.0
879
-     */
876
+	/**
877
+	 * Add auto paragraphs to text areas
878
+	 * @since 2.0
879
+	 */
880 880
 	public static function use_wpautop( $content ) {
881 881
 		if ( apply_filters( 'frm_use_wpautop', true ) ) {
882 882
 			$content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -885,26 +885,26 @@  discard block
 block discarded – undo
885 885
 	}
886 886
 
887 887
 	public static function replace_quotes( $val ) {
888
-        //Replace double quotes
888
+		//Replace double quotes
889 889
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
890
-        //Replace single quotes
891
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
892
-        return $val;
893
-    }
894
-
895
-    /**
896
-     * @since 2.0
897
-     * @return string The base Google APIS url for the current version of jQuery UI
898
-     */
899
-    public static function jquery_ui_base_url() {
890
+		//Replace single quotes
891
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
892
+		return $val;
893
+	}
894
+
895
+	/**
896
+	 * @since 2.0
897
+	 * @return string The base Google APIS url for the current version of jQuery UI
898
+	 */
899
+	public static function jquery_ui_base_url() {
900 900
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
901 901
 		$url = apply_filters( 'frm_jquery_ui_base_url', $url );
902
-        return $url;
903
-    }
902
+		return $url;
903
+	}
904 904
 
905
-    /**
906
-     * @param string $handle
907
-     */
905
+	/**
906
+	 * @param string $handle
907
+	 */
908 908
 	public static function script_version( $handle, $default = 0 ) {
909 909
 		global $wp_scripts;
910 910
 		if ( ! $wp_scripts ) {
@@ -926,12 +926,12 @@  discard block
 block discarded – undo
926 926
 
927 927
 	public static function js_redirect( $url ) {
928 928
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
929
-    }
929
+	}
930 930
 
931 931
 	public static function get_user_id_param( $user_id ) {
932 932
 		if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
933
-            return $user_id;
934
-        }
933
+			return $user_id;
934
+		}
935 935
 
936 936
 		$user_id = sanitize_text_field( $user_id );
937 937
 		if ( $user_id == 'current' ) {
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 				$user = get_user_by( 'login', $user_id );
944 944
 			}
945 945
 
946
-            if ( $user ) {
947
-                $user_id = $user->ID;
948
-            }
946
+			if ( $user ) {
947
+				$user_id = $user->ID;
948
+			}
949 949
 			unset( $user );
950
-        }
950
+		}
951 951
 
952
-        return $user_id;
953
-    }
952
+		return $user_id;
953
+	}
954 954
 
955 955
 	public static function get_file_contents( $filename, $atts = array() ) {
956 956
 		if ( ! is_file( $filename ) ) {
@@ -965,28 +965,28 @@  discard block
 block discarded – undo
965 965
 		return $contents;
966 966
 	}
967 967
 
968
-    /**
969
-     * @param string $table_name
970
-     * @param string $column
968
+	/**
969
+	 * @param string $table_name
970
+	 * @param string $column
971 971
 	 * @param int $id
972 972
 	 * @param int $num_chars
973
-     */
974
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
975
-        $key = '';
973
+	 */
974
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
975
+		$key = '';
976 976
 
977
-        if ( ! empty( $name ) ) {
977
+		if ( ! empty( $name ) ) {
978 978
 			$key = sanitize_key( $name );
979
-        }
979
+		}
980 980
 
981 981
 		if ( empty( $key ) ) {
982 982
 			$max_slug_value = pow( 36, $num_chars );
983
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
983
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
984 984
 			$key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
985
-        }
985
+		}
986 986
 
987 987
 		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
988 988
 			$key = $key . 'a';
989
-        }
989
+		}
990 990
 
991 991
 		$key_check = FrmDb::get_var( $table_name, array(
992 992
 			$column => $key,
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 		), $column );
995 995
 
996 996
 		if ( $key_check || is_numeric( $key_check ) ) {
997
-            $suffix = 2;
997
+			$suffix = 2;
998 998
 			do {
999 999
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1000 1000
 				$key_check = FrmDb::get_var( $table_name, array(
@@ -1004,19 +1004,19 @@  discard block
 block discarded – undo
1004 1004
 				$suffix++;
1005 1005
 			} while ( $key_check || is_numeric( $key_check ) );
1006 1006
 			$key = $alt_post_name;
1007
-        }
1008
-        return $key;
1009
-    }
1010
-
1011
-    /**
1012
-     * Editing a Form or Entry
1013
-     * @param string $table
1014
-     * @return bool|array
1015
-     */
1016
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1017
-        if ( ! $record ) {
1018
-            return false;
1019
-        }
1007
+		}
1008
+		return $key;
1009
+	}
1010
+
1011
+	/**
1012
+	 * Editing a Form or Entry
1013
+	 * @param string $table
1014
+	 * @return bool|array
1015
+	 */
1016
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1017
+		if ( ! $record ) {
1018
+			return false;
1019
+		}
1020 1020
 
1021 1021
 		if ( empty( $post_values ) ) {
1022 1022
 			$post_values = stripslashes_deep( $_POST );
@@ -1039,14 +1039,14 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1041 1041
 
1042
-        if ( $table == 'entries' ) {
1043
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1044
-        } else if ( $table == 'forms' ) {
1045
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1046
-        }
1042
+		if ( $table == 'entries' ) {
1043
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1044
+		} else if ( $table == 'forms' ) {
1045
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1046
+		}
1047 1047
 
1048
-        return $values;
1049
-    }
1048
+		return $values;
1049
+	}
1050 1050
 
1051 1051
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1052 1052
 		if ( ! empty( $fields ) ) {
@@ -1059,46 +1059,46 @@  discard block
 block discarded – undo
1059 1059
 	}
1060 1060
 
1061 1061
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1062
-        $post_values = $args['post_values'];
1062
+		$post_values = $args['post_values'];
1063 1063
 
1064
-        if ( $args['default'] ) {
1065
-            $meta_value = $field->default_value;
1066
-        } else {
1064
+		if ( $args['default'] ) {
1065
+			$meta_value = $field->default_value;
1066
+		} else {
1067 1067
 			if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1068 1068
 				if ( ! isset( $field->field_options['custom_field'] ) ) {
1069
-                    $field->field_options['custom_field'] = '';
1070
-                }
1069
+					$field->field_options['custom_field'] = '';
1070
+				}
1071 1071
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
1072 1072
 					'truncate' => false,
1073 1073
 					'type' => $field->type,
1074 1074
 					'form_id' => $field->form_id,
1075 1075
 					'field' => $field,
1076 1076
 				) );
1077
-            } else {
1077
+			} else {
1078 1078
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1079
-            }
1080
-        }
1079
+			}
1080
+		}
1081 1081
 
1082 1082
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1083
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1083
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1084 1084
 
1085 1085
 		$field_array = self::start_field_array( $field );
1086 1086
 		$field_array['value'] = $new_value;
1087 1087
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1088 1088
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1089 1089
 
1090
-        $args['field_type'] = $field_type;
1090
+		$args['field_type'] = $field_type;
1091 1091
 
1092 1092
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1093 1093
 
1094 1094
 		if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1095
-            $field_array['unique_msg'] = '';
1096
-        }
1095
+			$field_array['unique_msg'] = '';
1096
+		}
1097 1097
 
1098
-        $field_array = array_merge( $field->field_options, $field_array );
1098
+		$field_array = array_merge( $field->field_options, $field_array );
1099 1099
 
1100
-        $values['fields'][ $field->id ] = $field_array;
1101
-    }
1100
+		$values['fields'][ $field->id ] = $field_array;
1101
+	}
1102 1102
 
1103 1103
 	/**
1104 1104
 	 * @since 3.0
@@ -1119,20 +1119,20 @@  discard block
 block discarded – undo
1119 1119
 		);
1120 1120
 	}
1121 1121
 
1122
-    /**
1123
-     * @param string $table
1124
-     */
1122
+	/**
1123
+	 * @param string $table
1124
+	 */
1125 1125
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1126
-        if ( $table == 'entries' ) {
1127
-            $form = $record->form_id;
1126
+		if ( $table == 'entries' ) {
1127
+			$form = $record->form_id;
1128 1128
 			FrmForm::maybe_get_form( $form );
1129
-        } else {
1130
-            $form = $record;
1131
-        }
1129
+		} else {
1130
+			$form = $record;
1131
+		}
1132 1132
 
1133
-        if ( ! $form ) {
1134
-            return;
1135
-        }
1133
+		if ( ! $form ) {
1134
+			return;
1135
+		}
1136 1136
 
1137 1137
 		$values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1138 1138
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
@@ -1141,26 +1141,26 @@  discard block
 block discarded – undo
1141 1141
 			return;
1142 1142
 		}
1143 1143
 
1144
-        foreach ( $form->options as $opt => $value ) {
1145
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1146
-        }
1144
+		foreach ( $form->options as $opt => $value ) {
1145
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1146
+		}
1147 1147
 
1148 1148
 		self::fill_form_defaults( $post_values, $values );
1149
-    }
1149
+	}
1150 1150
 
1151
-    /**
1152
-     * Set to POST value or default
1153
-     */
1151
+	/**
1152
+	 * Set to POST value or default
1153
+	 */
1154 1154
 	private static function fill_form_defaults( $post_values, array &$values ) {
1155
-        $form_defaults = FrmFormsHelper::get_default_opts();
1155
+		$form_defaults = FrmFormsHelper::get_default_opts();
1156 1156
 
1157
-        foreach ( $form_defaults as $opt => $default ) {
1158
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1157
+		foreach ( $form_defaults as $opt => $default ) {
1158
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1159 1159
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1160
-            }
1160
+			}
1161 1161
 
1162 1162
 			unset( $opt, $default );
1163
-        }
1163
+		}
1164 1164
 
1165 1165
 		if ( ! isset( $values['custom_style'] ) ) {
1166 1166
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1169,10 +1169,10 @@  discard block
 block discarded – undo
1169 1169
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1170 1170
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1171 1171
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1172
-            }
1172
+			}
1173 1173
 			unset( $h );
1174
-        }
1175
-    }
1174
+		}
1175
+	}
1176 1176
 
1177 1177
 	/**
1178 1178
 	 * @since 2.2.10
@@ -1195,33 +1195,33 @@  discard block
 block discarded – undo
1195 1195
 		if ( $possible_email_field ) {
1196 1196
 			$class .= 'show_frm_not_email_to';
1197 1197
 		}
1198
-    ?>
1198
+	?>
1199 1199
 <li>
1200 1200
 	<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>
1201 1201
 	<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>
1202 1202
 	<a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ); ?></a>
1203 1203
 </li>
1204 1204
     <?php
1205
-    }
1205
+	}
1206 1206
 
1207 1207
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1208
-        if ( is_array( $str ) ) {
1209
-            return '';
1208
+		if ( is_array( $str ) ) {
1209
+			return '';
1210 1210
 		}
1211 1211
 
1212
-        $length = (int) $length;
1212
+		$length = (int) $length;
1213 1213
 		$str = wp_strip_all_tags( $str );
1214 1214
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1215 1215
 
1216 1216
 		if ( $length == 0 ) {
1217
-            return '';
1218
-        } else if ( $length <= 10 ) {
1217
+			return '';
1218
+		} else if ( $length <= 10 ) {
1219 1219
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1220 1220
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1221
-        }
1221
+		}
1222 1222
 
1223
-        $sub = '';
1224
-        $len = 0;
1223
+		$sub = '';
1224
+		$len = 0;
1225 1225
 
1226 1226
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1227 1227
 
@@ -1229,21 +1229,21 @@  discard block
 block discarded – undo
1229 1229
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1230 1230
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1231 1231
 			if ( $total_len > $length && str_word_count( $sub ) ) {
1232
-                break;
1233
-            }
1232
+				break;
1233
+			}
1234 1234
 
1235
-            $sub .= $part;
1235
+			$sub .= $part;
1236 1236
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1237 1237
 
1238 1238
 			if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1239
-                break;
1240
-            }
1239
+				break;
1240
+			}
1241 1241
 
1242 1242
 			unset( $total_len, $word );
1243
-        }
1243
+		}
1244 1244
 
1245 1245
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1246
-    }
1246
+	}
1247 1247
 
1248 1248
 	public static function mb_function( $function_names, $args ) {
1249 1249
 		$mb_function_name = $function_names[0];
@@ -1256,17 +1256,17 @@  discard block
 block discarded – undo
1256 1256
 
1257 1257
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1258 1258
 		if ( empty( $date ) ) {
1259
-            return $date;
1260
-        }
1259
+			return $date;
1260
+		}
1261 1261
 
1262 1262
 		if ( empty( $date_format ) ) {
1263 1263
 			$date_format = get_option( 'date_format' );
1264 1264
 		}
1265 1265
 
1266 1266
 		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1267
-            $frmpro_settings = new FrmProSettings();
1267
+			$frmpro_settings = new FrmProSettings();
1268 1268
 			$date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1269
-        }
1269
+		}
1270 1270
 
1271 1271
 		$formatted = self::get_localized_date( $date_format, $date );
1272 1272
 
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 			$formatted .= self::add_time_to_date( $time_format, $date );
1276 1276
 		}
1277 1277
 
1278
-        return $formatted;
1279
-    }
1278
+		return $formatted;
1279
+	}
1280 1280
 
1281 1281
 	private static function add_time_to_date( $time_format, $date ) {
1282 1282
 		if ( empty( $time_format ) ) {
@@ -1358,32 +1358,32 @@  discard block
 block discarded – undo
1358 1358
 		);
1359 1359
 	}
1360 1360
 
1361
-    // Pagination Methods
1361
+	// Pagination Methods
1362 1362
 
1363
-    /**
1364
-     * @param integer $current_p
1365
-     */
1363
+	/**
1364
+	 * @param integer $current_p
1365
+	 */
1366 1366
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1367 1367
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1368 1368
 	}
1369 1369
 
1370
-    /**
1371
-     * @param integer $current_p
1372
-     */
1373
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1374
-        if ( $current_p == 1 ) {
1375
-            return 1;
1376
-        } else {
1377
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1378
-        }
1379
-    }
1370
+	/**
1371
+	 * @param integer $current_p
1372
+	 */
1373
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1374
+		if ( $current_p == 1 ) {
1375
+			return 1;
1376
+		} else {
1377
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1378
+		}
1379
+	}
1380 1380
 
1381 1381
 	/**
1382 1382
 	 * @return array
1383 1383
 	 */
1384 1384
 	public static function json_to_array( $json_vars ) {
1385
-        $vars = array();
1386
-        foreach ( $json_vars as $jv ) {
1385
+		$vars = array();
1386
+		foreach ( $json_vars as $jv ) {
1387 1387
 			$jv_name = explode( '[', $jv['name'] );
1388 1388
 			$last = count( $jv_name ) - 1;
1389 1389
 			foreach ( $jv_name as $p => $n ) {
@@ -1400,77 +1400,77 @@  discard block
 block discarded – undo
1400 1400
 					$l3 = $name;
1401 1401
 				}
1402 1402
 
1403
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1403
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1404 1404
 
1405
-                switch ( $p ) {
1406
-                    case 0:
1407
-                        $l1 = $name;
1408
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1405
+				switch ( $p ) {
1406
+					case 0:
1407
+						$l1 = $name;
1408
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1409 1409
 						break;
1410 1410
 
1411
-                    case 1:
1412
-                        $l2 = $name;
1413
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1411
+					case 1:
1412
+						$l2 = $name;
1413
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1414 1414
 						break;
1415 1415
 
1416
-                    case 2:
1417
-                        $l3 = $name;
1418
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1416
+					case 2:
1417
+						$l3 = $name;
1418
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1419 1419
 						break;
1420 1420
 
1421
-                    case 3:
1422
-                        $l4 = $name;
1423
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1424
-                }
1421
+					case 3:
1422
+						$l4 = $name;
1423
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1424
+				}
1425 1425
 
1426 1426
 				unset( $this_val, $n );
1427
-            }
1427
+			}
1428 1428
 
1429 1429
 			unset( $last, $jv );
1430
-        }
1431
-
1432
-        return $vars;
1433
-    }
1434
-
1435
-    /**
1436
-     * @param string $name
1437
-     * @param string $l1
1438
-     */
1439
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1440
-        if ( $name == '' ) {
1441
-            $vars[] = $val;
1442
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1443
-            $vars[ $l1 ] = $val;
1444
-        }
1445
-    }
1430
+		}
1431
+
1432
+		return $vars;
1433
+	}
1434
+
1435
+	/**
1436
+	 * @param string $name
1437
+	 * @param string $l1
1438
+	 */
1439
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1440
+		if ( $name == '' ) {
1441
+			$vars[] = $val;
1442
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1443
+			$vars[ $l1 ] = $val;
1444
+		}
1445
+	}
1446 1446
 
1447 1447
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1448
-        $tooltips = array(
1449
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1450
-            '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' ),
1451
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1452
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1453
-            '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' ),
1454
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1455
-            '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() ) ),
1456
-        );
1457
-
1458
-        if ( ! isset( $tooltips[ $name ] ) ) {
1459
-            return;
1460
-        }
1461
-
1462
-        if ( 'open' == $class ) {
1463
-            echo ' frm_help"';
1464
-        } else {
1465
-            echo ' class="frm_help"';
1466
-        }
1448
+		$tooltips = array(
1449
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1450
+			'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' ),
1451
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1452
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1453
+			'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' ),
1454
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1455
+			'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() ) ),
1456
+		);
1457
+
1458
+		if ( ! isset( $tooltips[ $name ] ) ) {
1459
+			return;
1460
+		}
1461
+
1462
+		if ( 'open' == $class ) {
1463
+			echo ' frm_help"';
1464
+		} else {
1465
+			echo ' class="frm_help"';
1466
+		}
1467 1467
 
1468 1468
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1469 1469
 
1470
-        if ( 'open' != $class ) {
1471
-            echo '"';
1472
-        }
1473
-    }
1470
+		if ( 'open' != $class ) {
1471
+			echo '"';
1472
+		}
1473
+	}
1474 1474
 
1475 1475
 	/**
1476 1476
 	 * Add the current_page class to that page in the form nav
@@ -1486,35 +1486,35 @@  discard block
 block discarded – undo
1486 1486
 		}
1487 1487
 	}
1488 1488
 
1489
-    /**
1490
-     * Prepare and json_encode post content
1491
-     *
1492
-     * @since 2.0
1493
-     *
1494
-     * @param array $post_content
1495
-     * @return string $post_content ( json encoded array )
1496
-     */
1497
-    public static function prepare_and_encode( $post_content ) {
1498
-        //Loop through array to strip slashes and add only the needed ones
1489
+	/**
1490
+	 * Prepare and json_encode post content
1491
+	 *
1492
+	 * @since 2.0
1493
+	 *
1494
+	 * @param array $post_content
1495
+	 * @return string $post_content ( json encoded array )
1496
+	 */
1497
+	public static function prepare_and_encode( $post_content ) {
1498
+		//Loop through array to strip slashes and add only the needed ones
1499 1499
 		foreach ( $post_content as $key => $val ) {
1500 1500
 			// Replace problematic characters (like &quot;)
1501 1501
 			$val = str_replace( '&quot;', '"', $val );
1502 1502
 
1503 1503
 			self::prepare_action_slashes( $val, $key, $post_content );
1504
-            unset( $key, $val );
1505
-        }
1504
+			unset( $key, $val );
1505
+		}
1506 1506
 
1507
-        // json_encode the array
1508
-        $post_content = json_encode( $post_content );
1507
+		// json_encode the array
1508
+		$post_content = json_encode( $post_content );
1509 1509
 
1510
-	    // add extra slashes for \r\n since WP strips them
1510
+		// add extra slashes for \r\n since WP strips them
1511 1511
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1512 1512
 
1513
-        // allow for &quot
1514
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1513
+		// allow for &quot
1514
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1515 1515
 
1516
-        return $post_content;
1517
-    }
1516
+		return $post_content;
1517
+	}
1518 1518
 
1519 1519
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1520 1520
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1537,63 +1537,63 @@  discard block
 block discarded – undo
1537 1537
 
1538 1538
 	public static function maybe_json_decode( $string ) {
1539 1539
 		if ( is_array( $string ) ) {
1540
-            return $string;
1541
-        }
1540
+			return $string;
1541
+		}
1542 1542
 
1543 1543
 		$new_string = json_decode( $string, true );
1544 1544
 		if ( function_exists( 'json_last_error' ) ) {
1545 1545
 			// php 5.3+
1546
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1547
-                $string = $new_string;
1548
-            }
1546
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1547
+				$string = $new_string;
1548
+			}
1549 1549
 		} elseif ( isset( $new_string ) ) {
1550 1550
 			// php < 5.3 fallback
1551
-            $string = $new_string;
1552
-        }
1553
-        return $string;
1554
-    }
1555
-
1556
-    /**
1557
-     * @since 1.07.10
1558
-     *
1559
-     * @param string $post_type The name of the post type that may need to be highlighted
1560
-     * echo The javascript to open and highlight the Formidable menu
1561
-     */
1551
+			$string = $new_string;
1552
+		}
1553
+		return $string;
1554
+	}
1555
+
1556
+	/**
1557
+	 * @since 1.07.10
1558
+	 *
1559
+	 * @param string $post_type The name of the post type that may need to be highlighted
1560
+	 * echo The javascript to open and highlight the Formidable menu
1561
+	 */
1562 1562
 	public static function maybe_highlight_menu( $post_type ) {
1563
-        global $post;
1563
+		global $post;
1564 1564
 
1565 1565
 		if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1566
-            return;
1567
-        }
1566
+			return;
1567
+		}
1568 1568
 
1569 1569
 		if ( is_object( $post ) && $post->post_type != $post_type ) {
1570
-            return;
1571
-        }
1570
+			return;
1571
+		}
1572 1572
 
1573
-        self::load_admin_wide_js();
1574
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1575
-    }
1573
+		self::load_admin_wide_js();
1574
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1575
+	}
1576 1576
 
1577
-    /**
1578
-     * Load the JS file on non-Formidable pages in the admin area
1579
-     * @since 2.0
1580
-     */
1577
+	/**
1578
+	 * Load the JS file on non-Formidable pages in the admin area
1579
+	 * @since 2.0
1580
+	 */
1581 1581
 	public static function load_admin_wide_js( $load = true ) {
1582
-        $version = FrmAppHelper::plugin_version();
1582
+		$version = FrmAppHelper::plugin_version();
1583 1583
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1584 1584
 
1585
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1585
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1586 1586
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1587
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1587
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1588 1588
 			'url'          => FrmAppHelper::plugin_url(),
1589 1589
 			'loading'      => __( 'Loading&hellip;' ),
1590 1590
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1591
-        ) );
1591
+		) );
1592 1592
 
1593 1593
 		if ( $load ) {
1594 1594
 			wp_enqueue_script( 'formidable_admin_global' );
1595 1595
 		}
1596
-    }
1596
+	}
1597 1597
 
1598 1598
 	/**
1599 1599
 	 * @since 2.0.9
@@ -1602,9 +1602,9 @@  discard block
 block discarded – undo
1602 1602
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1603 1603
 	}
1604 1604
 
1605
-    /**
1606
-     * @param string $location
1607
-     */
1605
+	/**
1606
+	 * @param string $location
1607
+	 */
1608 1608
 	public static function localize_script( $location ) {
1609 1609
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1610 1610
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1664,27 +1664,27 @@  discard block
 block discarded – undo
1664 1664
 		}
1665 1665
 	}
1666 1666
 
1667
-    /**
1667
+	/**
1668 1668
 	 * echo the message on the plugins listing page
1669
-     * @since 1.07.10
1670
-     *
1671
-     * @param float $min_version The version the add-on requires
1672
-     */
1669
+	 * @since 1.07.10
1670
+	 *
1671
+	 * @param float $min_version The version the add-on requires
1672
+	 */
1673 1673
 	public static function min_version_notice( $min_version ) {
1674
-        $frm_version = self::plugin_version();
1674
+		$frm_version = self::plugin_version();
1675 1675
 
1676
-        // check if Formidable meets minimum requirements
1676
+		// check if Formidable meets minimum requirements
1677 1677
 		if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1678
-            return;
1679
-        }
1678
+			return;
1679
+		}
1680 1680
 
1681 1681
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1682 1682
 		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">' .
1683
-        esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1684
-        '</div></td></tr>';
1685
-    }
1683
+		esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1684
+		'</div></td></tr>';
1685
+	}
1686 1686
 
1687
-    public static function locales( $type = 'date' ) {
1687
+	public static function locales( $type = 'date' ) {
1688 1688
 		$locales = array(
1689 1689
 			'en' => __( 'English', 'formidable' ),
1690 1690
 			''   => __( 'English/Western', 'formidable' ),
@@ -1763,8 +1763,8 @@  discard block
 block discarded – undo
1763 1763
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1764 1764
 		$locales = apply_filters( 'frm_locales', $locales );
1765 1765
 
1766
-        return $locales;
1767
-    }
1766
+		return $locales;
1767
+	}
1768 1768
 
1769 1769
 	/**
1770 1770
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.
classes/helpers/FrmFormsHelper.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -16,28 +16,28 @@  discard block
 block discarded – undo
16 16
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
17 17
 		$target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
18 18
 
19
-        return $target_url;
20
-    }
21
-
22
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
23
-        $defaults = array(
24
-            'blank'     => true,
25
-            'field_id'  => false,
26
-            'onchange'  => false,
27
-            'exclude'   => false,
28
-            'class'     => '',
19
+		return $target_url;
20
+	}
21
+
22
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
23
+		$defaults = array(
24
+			'blank'     => true,
25
+			'field_id'  => false,
26
+			'onchange'  => false,
27
+			'exclude'   => false,
28
+			'class'     => '',
29 29
 			'inc_children' => 'exclude',
30
-        );
31
-        $args = wp_parse_args( $args, $defaults );
30
+		);
31
+		$args = wp_parse_args( $args, $defaults );
32 32
 
33
-        if ( ! $args['field_id'] ) {
34
-            $args['field_id'] = $field_name;
35
-        }
33
+		if ( ! $args['field_id'] ) {
34
+			$args['field_id'] = $field_name;
35
+		}
36 36
 
37 37
 		$query = array();
38
-        if ( $args['exclude'] ) {
38
+		if ( $args['exclude'] ) {
39 39
 			$query['id !'] = $args['exclude'];
40
-        }
40
+		}
41 41
 
42 42
 		$where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
43 43
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
46 46
 		self::add_html_attr( $args['class'], 'class', $add_html );
47 47
 
48
-        ?>
48
+		?>
49 49
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo wp_strip_all_tags( implode( ' ', $add_html ) ); // WPCS: XSS ok. ?>>
50 50
 		<?php if ( $args['blank'] ) { ?>
51 51
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		<?php } ?>
58 58
         </select>
59 59
         <?php
60
-    }
60
+	}
61 61
 
62 62
 	/**
63 63
 	 * @param string $class
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 	}
74 74
 
75
-    public static function form_switcher() {
75
+	public static function form_switcher() {
76 76
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
77 77
 		$forms = FrmForm::get_published_forms( $where );
78 78
 
@@ -84,32 +84,32 @@  discard block
 block discarded – undo
84 84
 			unset( $args['form'] );
85 85
 		} elseif ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
86 86
 			unset( $args['id'] );
87
-        }
87
+		}
88 88
 
89 89
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
90 90
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
91
-            $args['frm_action'] = 'list';
92
-            $args['form'] = 0;
91
+			$args['frm_action'] = 'list';
92
+			$args['form'] = 0;
93 93
 		} elseif ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
94
-            $args['frm_action'] = 'edit';
94
+			$args['frm_action'] = 'edit';
95 95
 		} else if ( isset( $_GET['post'] ) ) {
96
-            $args['form'] = 0;
96
+			$args['form'] = 0;
97 97
 			$base = admin_url( 'edit.php?post_type=frm_display' );
98
-        }
98
+		}
99 99
 
100
-        ?>
100
+		?>
101 101
 		<li id="frm_bs_dropdown" class="dropdown <?php echo esc_attr( is_rtl() ? 'pull-right' : 'pull-left' ) ?>">
102 102
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php esc_html_e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
103 103
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
104 104
 			<?php
105 105
 			foreach ( $forms as $form ) {
106 106
 				if ( isset( $args['id'] ) ) {
107
-			        $args['id'] = $form->id;
107
+					$args['id'] = $form->id;
108 108
 				}
109
-			    if ( isset( $args['form'] ) ) {
110
-			        $args['form'] = $form->id;
109
+				if ( isset( $args['form'] ) ) {
110
+					$args['form'] = $form->id;
111 111
 				}
112
-                ?>
112
+				?>
113 113
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
114 114
 			<?php
115 115
 				unset( $form );
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			</ul>
119 119
 		</li>
120 120
         <?php
121
-    }
121
+	}
122 122
 
123 123
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
124 124
 		echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
 		return $message;
170 170
 	}
171 171
 
172
-    /**
173
-     * Used when a form is created
174
-     */
175
-    public static function setup_new_vars( $values = array() ) {
176
-        global $wpdb;
172
+	/**
173
+	 * Used when a form is created
174
+	 */
175
+	public static function setup_new_vars( $values = array() ) {
176
+		global $wpdb;
177 177
 
178
-        if ( ! empty( $values ) ) {
179
-            $post_values = $values;
180
-        } else {
181
-            $values = array();
178
+		if ( ! empty( $values ) ) {
179
+			$post_values = $values;
180
+		} else {
181
+			$values = array();
182 182
 			$post_values = isset( $_POST ) ? $_POST : array();
183
-        }
183
+		}
184 184
 
185 185
 		$defaults = array(
186 186
 			'name' => '',
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 		foreach ( $defaults as $var => $default ) {
190 190
 			if ( ! isset( $values[ $var ] ) ) {
191 191
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
192
-            }
193
-        }
192
+			}
193
+		}
194 194
 
195 195
 		$values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
196 196
 
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
 		}
211 211
 		unset( $defaults );
212 212
 
213
-        if ( ! isset( $values['form_key'] ) ) {
213
+		if ( ! isset( $values['form_key'] ) ) {
214 214
 			$values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
215
-        }
215
+		}
216 216
 
217 217
 		$values = self::fill_default_opts( $values, false, $post_values );
218 218
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
219 219
 
220 220
 		return apply_filters( 'frm_setup_new_form_vars', $values );
221
-    }
221
+	}
222 222
 
223
-    /**
224
-     * Used when editing a form
225
-     */
226
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
223
+	/**
224
+	 * Used when editing a form
225
+	 */
226
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
227 227
 		if ( empty( $post_values ) ) {
228 228
 			$post_values = stripslashes_deep( $_POST );
229 229
 		}
@@ -231,43 +231,43 @@  discard block
 block discarded – undo
231 231
 		$values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
232 232
 		$values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
233 233
 		$values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
234
-        $values['status'] = $record->status;
234
+		$values['status'] = $record->status;
235 235
 
236 236
 		$values = self::fill_default_opts( $values, $record, $post_values );
237 237
 
238 238
 		return apply_filters( 'frm_setup_edit_form_vars', $values );
239
-    }
239
+	}
240 240
 
241 241
 	public static function fill_default_opts( $values, $record, $post_values ) {
242 242
 
243
-        $defaults = self::get_default_opts();
243
+		$defaults = self::get_default_opts();
244 244
 		foreach ( $defaults as $var => $default ) {
245 245
 			if ( is_array( $default ) ) {
246
-                if ( ! isset( $values[ $var ] ) ) {
246
+				if ( ! isset( $values[ $var ] ) ) {
247 247
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
248
-                }
248
+				}
249 249
 
250
-                foreach ( $default as $k => $v ) {
250
+				foreach ( $default as $k => $v ) {
251 251
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v );
252 252
 
253
-                    if ( is_array( $v ) ) {
254
-                        foreach ( $v as $k1 => $v1 ) {
253
+					if ( is_array( $v ) ) {
254
+						foreach ( $v as $k1 => $v1 ) {
255 255
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
256
-                            unset( $k1, $v1 );
257
-                        }
258
-                    }
256
+							unset( $k1, $v1 );
257
+						}
258
+					}
259 259
 
260 260
 					unset( $k, $v );
261
-                }
262
-            } else {
261
+				}
262
+			} else {
263 263
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
264
-            }
264
+			}
265 265
 
266 266
 			unset( $var, $default );
267
-        }
267
+		}
268 268
 
269
-        return $values;
270
-    }
269
+		return $values;
270
+	}
271 271
 
272 272
 	public static function get_default_opts() {
273 273
 		$frm_settings = FrmAppHelper::get_settings();
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
 		}
303 303
 	}
304 304
 
305
-    /**
306
-     * @param string $loc
307
-     */
305
+	/**
306
+	 * @param string $loc
307
+	 */
308 308
 	public static function get_default_html( $loc ) {
309 309
 		if ( $loc == 'submit' ) {
310
-            $draft_link = self::get_draft_link();
311
-            $default_html = <<<SUBMIT_HTML
310
+			$draft_link = self::get_draft_link();
311
+			$default_html = <<<SUBMIT_HTML
312 312
 <div class="frm_submit">
313 313
 [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
314 314
 <button class="frm_button_submit" type="submit"  [button_action]>[button_label]</button>
@@ -316,22 +316,22 @@  discard block
 block discarded – undo
316 316
 </div>
317 317
 SUBMIT_HTML;
318 318
 		} else if ( $loc == 'before' ) {
319
-            $default_html = <<<BEFORE_HTML
319
+			$default_html = <<<BEFORE_HTML
320 320
 <legend class="frm_screen_reader">[form_name]</legend>
321 321
 [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name]
322 322
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
323 323
 BEFORE_HTML;
324 324
 		} else {
325
-            $default_html = '';
326
-        }
325
+			$default_html = '';
326
+		}
327 327
 
328
-        return $default_html;
329
-    }
328
+		return $default_html;
329
+	}
330 330
 
331
-    public static function get_draft_link() {
332
-        $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
333
-        return $link;
334
-    }
331
+	public static function get_draft_link() {
332
+		$link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
333
+		return $link;
334
+	}
335 335
 
336 336
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
337 337
 		$button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
 		echo $button_parts[1]; // WPCS: XSS ok.
359 359
 	}
360 360
 
361
-    /**
362
-     * Automatically add end section fields if they don't exist (2.0 migration)
363
-     * @since 2.0
364
-     *
365
-     * @param boolean $reset_fields
366
-     */
367
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
361
+	/**
362
+	 * Automatically add end section fields if they don't exist (2.0 migration)
363
+	 * @since 2.0
364
+	 *
365
+	 * @param boolean $reset_fields
366
+	 */
367
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
368 368
 		if ( empty( $fields ) ) {
369 369
 			return;
370 370
 		}
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 		$prev_order = false;
375 375
 		$add_order = 0;
376 376
 		$last_field = false;
377
-        foreach ( $fields as $field ) {
377
+		foreach ( $fields as $field ) {
378 378
 			if ( $prev_order === $field->field_order ) {
379 379
 				$add_order++;
380 380
 			}
@@ -385,48 +385,48 @@  discard block
 block discarded – undo
385 385
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
386 386
 			}
387 387
 
388
-            switch ( $field->type ) {
389
-                case 'divider':
390
-                    // create an end section if open
388
+			switch ( $field->type ) {
389
+				case 'divider':
390
+					// create an end section if open
391 391
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
392 392
 
393
-                    // mark it open for the next end section
394
-                    $open = true;
393
+					// mark it open for the next end section
394
+					$open = true;
395 395
 					break;
396
-                case 'break':
396
+				case 'break':
397 397
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
398 398
 					break;
399
-                case 'end_divider':
400
-                    if ( ! $open ) {
401
-                        // the section isn't open, so this is an extra field that needs to be removed
402
-                        FrmField::destroy( $field->id );
403
-                        $reset_fields = true;
404
-                    }
405
-
406
-                    // There is already an end section here, so there is no need to create one
407
-                    $open = false;
408
-            }
399
+				case 'end_divider':
400
+					if ( ! $open ) {
401
+						// the section isn't open, so this is an extra field that needs to be removed
402
+						FrmField::destroy( $field->id );
403
+						$reset_fields = true;
404
+					}
405
+
406
+					// There is already an end section here, so there is no need to create one
407
+					$open = false;
408
+			}
409 409
 			$prev_order = $field->field_order;
410 410
 
411 411
 			$last_field = $field;
412 412
 			unset( $field );
413
-        }
413
+		}
414 414
 
415 415
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
416
-    }
416
+	}
417 417
 
418 418
 	/**
419 419
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
420 420
 	 * Fix any ordering that may be messed up
421 421
 	 */
422 422
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
423
-        if ( ! $open ) {
424
-            return;
425
-        }
423
+		if ( ! $open ) {
424
+			return;
425
+		}
426 426
 
427 427
 		$end_section_values['field_order'] = $field->field_order + 1;
428 428
 
429
-        FrmField::create( $end_section_values );
429
+		FrmField::create( $end_section_values );
430 430
 
431 431
 		if ( $move == 'move' ) {
432 432
 			// bump the order of current field unless we're at the end of the form
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
 		}
435 435
 
436 436
 		$add_order += 2;
437
-        $open = false;
438
-        $reset_fields = true;
439
-    }
437
+		$open = false;
438
+		$reset_fields = true;
439
+	}
440 440
 
441 441
 	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
442 442
 		$codes = array(
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 			}
457 457
 
458 458
 			FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
459
-        }
459
+		}
460 460
 
461 461
 		//replace [form_key]
462 462
 		$html = str_replace( '[form_key]', $form->form_key, $html );
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 			$submit_label = apply_filters( 'frm_submit_button', $title, $form );
470 470
 			$submit_label = esc_attr( do_shortcode( $submit_label ) );
471 471
 			$html = str_replace( '[button_label]', $submit_label, $html );
472
-        }
472
+		}
473 473
 
474 474
 		$html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
475 475
 
@@ -485,17 +485,17 @@  discard block
 block discarded – undo
485 485
 			$html = do_shortcode( $html );
486 486
 		}
487 487
 
488
-        return $html;
489
-    }
488
+		return $html;
489
+	}
490 490
 
491 491
 	public static function submit_button_label( $submit ) {
492 492
 		if ( ! $submit || empty( $submit ) ) {
493
-            $frm_settings = FrmAppHelper::get_settings();
494
-            $submit = $frm_settings->submit_value;
495
-        }
493
+			$frm_settings = FrmAppHelper::get_settings();
494
+			$submit = $frm_settings->submit_value;
495
+		}
496 496
 
497
-        return $submit;
498
-    }
497
+		return $submit;
498
+	}
499 499
 
500 500
 	/**
501 501
 	 * If the Formidable styling isn't being loaded,
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			}
524 524
 		}
525 525
 
526
-        //If submit button needs to be inline or centered
526
+		//If submit button needs to be inline or centered
527 527
 		if ( is_object( $form ) ) {
528 528
 			$form = $form->options;
529 529
 		}
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
 
540 540
 		$class = apply_filters( 'frm_add_form_style_class', $class, $style );
541 541
 
542
-        return $class;
543
-    }
542
+		return $class;
543
+	}
544 544
 
545 545
 	/**
546 546
 	 * Returns appropriate class if form has top labels
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
 		return in_array( $label_position, array( 'top', 'inside', 'hidden' ) );
596 596
 	}
597 597
 
598
-    /**
599
-     * @param string|boolean $form
600
-     *
601
-     * @return string
602
-     */
603
-    public static function get_form_style( $form ) {
598
+	/**
599
+	 * @param string|boolean $form
600
+	 *
601
+	 * @return string
602
+	 */
603
+	public static function get_form_style( $form ) {
604 604
 		$style = 1;
605 605
 		if ( empty( $form ) || 'default' == 'form' ) {
606 606
 			return $style;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
621 621
 
622 622
 		return $style;
623
-    }
623
+	}
624 624
 
625 625
 	/**
626 626
 	 * Display the validation error messages when an entry is submitted
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
 	}
690 690
 
691 691
 	public static function get_scroll_js( $form_id ) {
692
-        echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
693
-    }
692
+		echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
693
+	}
694 694
 
695 695
 	/**
696 696
 	 * @since 3.0
@@ -745,20 +745,20 @@  discard block
 block discarded – undo
745 745
 
746 746
 	public static function edit_form_link( $form_id ) {
747 747
 		if ( is_object( $form_id ) ) {
748
-            $form = $form_id;
749
-            $name = $form->name;
750
-            $form_id = $form->id;
751
-        } else {
748
+			$form = $form_id;
749
+			$name = $form->name;
750
+			$form_id = $form->id;
751
+		} else {
752 752
 			$name = FrmForm::getName( $form_id );
753
-        }
753
+		}
754 754
 
755
-        if ( $form_id ) {
755
+		if ( $form_id ) {
756 756
 			$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
757
-	    } else {
758
-	        $val = '';
759
-	    }
757
+		} else {
758
+			$val = '';
759
+		}
760 760
 
761
-	    return $val;
761
+		return $val;
762 762
 	}
763 763
 
764 764
 	public static function delete_trash_link( $id, $status, $length = 'label' ) {
@@ -939,18 +939,18 @@  discard block
 block discarded – undo
939 939
 	}
940 940
 
941 941
 	public static function status_nice_name( $status ) {
942
-        $nice_names = array(
943
-            'draft'     => __( 'Draft', 'formidable' ),
944
-            'trash'     => __( 'Trash', 'formidable' ),
945
-            'publish'   => __( 'Published', 'formidable' ),
946
-        );
942
+		$nice_names = array(
943
+			'draft'     => __( 'Draft', 'formidable' ),
944
+			'trash'     => __( 'Trash', 'formidable' ),
945
+			'publish'   => __( 'Published', 'formidable' ),
946
+		);
947 947
 
948 948
 		if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
949
-            $status = 'publish';
950
-        }
949
+			$status = 'publish';
950
+		}
951 951
 
952 952
 		$name = $nice_names[ $status ];
953 953
 
954
-        return $name;
955
-    }
954
+		return $name;
955
+	}
956 956
 }
Please login to merge, or discard this patch.