Completed
Push — master ( 9c2b3f...71978b )
by Stephanie
03:14
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +557 added lines, -557 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.04';
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(
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 			}
288 288
 		}
289 289
 
290
-        return $value;
291
-    }
290
+		return $value;
291
+	}
292 292
 
293 293
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
294 294
 		return self::get_simple_request(
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 	}
357 357
 
358 358
 	/**
359
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
360
-	*
361
-	* @since 2.0.8
362
-	* @param string $value
363
-	* @return string $value
364
-	*/
359
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
360
+	 *
361
+	 * @since 2.0.8
362
+	 * @param string $value
363
+	 * @return string $value
364
+	 */
365 365
 	public static function preserve_backslashes( $value ) {
366 366
 		// If backslashes have already been added, don't add them again
367 367
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
 		}
384 384
 	}
385 385
 
386
-    public static function sanitize_request( $sanitize_method, &$values ) {
387
-        $temp_values = $values;
388
-        foreach ( $temp_values as $k => $val ) {
389
-            if ( isset( $sanitize_method[ $k ] ) ) {
386
+	public static function sanitize_request( $sanitize_method, &$values ) {
387
+		$temp_values = $values;
388
+		foreach ( $temp_values as $k => $val ) {
389
+			if ( isset( $sanitize_method[ $k ] ) ) {
390 390
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
391
-            }
392
-        }
393
-    }
391
+			}
392
+		}
393
+	}
394 394
 
395 395
 	/**
396 396
 	 * @deprecated 3.01
@@ -516,39 +516,39 @@  discard block
 block discarded – undo
516 516
 		);
517 517
 	}
518 518
 
519
-    /**
520
-     * Used when switching the action for a bulk action
521
-     * @since 2.0
522
-     */
519
+	/**
520
+	 * Used when switching the action for a bulk action
521
+	 * @since 2.0
522
+	 */
523 523
 	public static function remove_get_action() {
524 524
 		if ( ! isset( $_GET ) ) {
525 525
 			return;
526 526
 		}
527 527
 
528
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
529
-        if ( ! empty( $new_action ) ) {
528
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
529
+		if ( ! empty( $new_action ) ) {
530 530
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
531
-        }
532
-    }
531
+		}
532
+	}
533 533
 
534
-    /**
535
-     * Check the WP query for a parameter
536
-     *
537
-     * @since 2.0
538
-     * @return string|array
539
-     */
540
-    public static function get_query_var( $value, $param ) {
541
-        if ( $value != '' ) {
542
-            return $value;
543
-        }
534
+	/**
535
+	 * Check the WP query for a parameter
536
+	 *
537
+	 * @since 2.0
538
+	 * @return string|array
539
+	 */
540
+	public static function get_query_var( $value, $param ) {
541
+		if ( $value != '' ) {
542
+			return $value;
543
+		}
544 544
 
545
-        global $wp_query;
546
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
547
-            $value = $wp_query->query_vars[ $param ];
548
-        }
545
+		global $wp_query;
546
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
547
+			$value = $wp_query->query_vars[ $param ];
548
+		}
549 549
 
550
-        return $value;
551
-    }
550
+		return $value;
551
+	}
552 552
 
553 553
 	/**
554 554
 	 * @since 3.0
@@ -570,16 +570,16 @@  discard block
 block discarded – undo
570 570
 		}
571 571
 	}
572 572
 
573
-    /**
574
-     * @param string $type
575
-     */
576
-    public static function trigger_hook_load( $type, $object = null ) {
577
-        // only load the form hooks once
573
+	/**
574
+	 * @param string $type
575
+	 */
576
+	public static function trigger_hook_load( $type, $object = null ) {
577
+		// only load the form hooks once
578 578
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
579
-        if ( ! $hooks_loaded ) {
579
+		if ( ! $hooks_loaded ) {
580 580
 			do_action( 'frm_load_' . $type . '_hooks' );
581
-        }
582
-    }
581
+		}
582
+	}
583 583
 
584 584
 	/**
585 585
 	 * Save all front-end js scripts into a single file
@@ -604,29 +604,29 @@  discard block
 block discarded – undo
604 604
 		$new_file->combine_files( $files );
605 605
 	}
606 606
 
607
-    /**
608
-     * Check a value from a shortcode to see if true or false.
609
-     * True when value is 1, true, 'true', 'yes'
610
-     *
611
-     * @since 1.07.10
612
-     *
613
-     * @param string $value The value to compare
614
-     * @return boolean True or False
615
-     */
607
+	/**
608
+	 * Check a value from a shortcode to see if true or false.
609
+	 * True when value is 1, true, 'true', 'yes'
610
+	 *
611
+	 * @since 1.07.10
612
+	 *
613
+	 * @param string $value The value to compare
614
+	 * @return boolean True or False
615
+	 */
616 616
 	public static function is_true( $value ) {
617
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
618
-    }
617
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
618
+	}
619 619
 
620
-    /**
621
-     * Used to filter shortcode in text widgets
620
+	/**
621
+	 * Used to filter shortcode in text widgets
622 622
 	 *
623 623
 	 * @deprecated 2.5.4
624 624
 	 * @codeCoverageIgnore
625
-     */
626
-    public static function widget_text_filter_callback( $matches ) {
625
+	 */
626
+	public static function widget_text_filter_callback( $matches ) {
627 627
 		_deprecated_function( __METHOD__, '2.5.4' );
628
-        return do_shortcode( $matches[0] );
629
-    }
628
+		return do_shortcode( $matches[0] );
629
+	}
630 630
 
631 631
 	public static function get_pages() {
632 632
 		$query = array(
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
 		return get_posts( $query );
640 640
 	}
641 641
 
642
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
643
-        $pages = self::get_pages();
642
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
643
+		$pages = self::get_pages();
644 644
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
645
-    ?>
645
+	?>
646 646
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
647 647
             <option value=""> </option>
648 648
             <?php foreach ( $pages as $page ) { ?>
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
             <?php } ?>
653 653
         </select>
654 654
     <?php
655
-    }
655
+	}
656 656
 
657 657
 	public static function post_edit_link( $post_id ) {
658 658
 		$post = get_post( $post_id );
659
-        if ( $post ) {
659
+		if ( $post ) {
660 660
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
661 661
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
662
-        }
663
-        return '';
664
-    }
662
+		}
663
+		return '';
664
+	}
665 665
 
666 666
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
667 667
 		?>
@@ -672,73 +672,73 @@  discard block
 block discarded – undo
672 672
 	}
673 673
 
674 674
 	public static function roles_options( $capability ) {
675
-        global $frm_vars;
675
+		global $frm_vars;
676 676
 		if ( isset( $frm_vars['editable_roles'] ) ) {
677
-            $editable_roles = $frm_vars['editable_roles'];
678
-        } else {
679
-            $editable_roles = get_editable_roles();
680
-            $frm_vars['editable_roles'] = $editable_roles;
681
-        }
677
+			$editable_roles = $frm_vars['editable_roles'];
678
+		} else {
679
+			$editable_roles = get_editable_roles();
680
+			$frm_vars['editable_roles'] = $editable_roles;
681
+		}
682 682
 
683
-        foreach ( $editable_roles as $role => $details ) {
683
+		foreach ( $editable_roles as $role => $details ) {
684 684
 			$name = translate_user_role( $details['name'] );
685 685
 			?>
686 686
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
687 687
 <?php
688 688
 			unset( $role, $details );
689
-        }
690
-    }
689
+		}
690
+	}
691 691
 
692 692
 	public static function frm_capabilities( $type = 'auto' ) {
693
-        $cap = array(
694
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
695
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
696
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
697
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
698
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
699
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
700
-        );
693
+		$cap = array(
694
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
695
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
696
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
697
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
698
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
699
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
700
+		);
701 701
 
702 702
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
703
-            return $cap;
704
-        }
703
+			return $cap;
704
+		}
705 705
 
706
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
707
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
708
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
709
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
706
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
707
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
708
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
709
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
710 710
 
711
-        return $cap;
712
-    }
711
+		return $cap;
712
+	}
713 713
 
714 714
 	public static function user_has_permission( $needed_role ) {
715
-        if ( $needed_role == '-1' ) {
716
-            return false;
715
+		if ( $needed_role == '-1' ) {
716
+			return false;
717 717
 		}
718 718
 
719
-        // $needed_role will be equal to blank if "Logged-in users" is selected
720
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
721
-            return true;
722
-        }
719
+		// $needed_role will be equal to blank if "Logged-in users" is selected
720
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
721
+			return true;
722
+		}
723 723
 
724
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
725
-        foreach ( $roles as $role ) {
724
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
725
+		foreach ( $roles as $role ) {
726 726
 			if ( current_user_can( $role ) ) {
727
-        		return true;
727
+				return true;
728 728
 			}
729
-        	if ( $role == $needed_role ) {
730
-        		break;
729
+			if ( $role == $needed_role ) {
730
+				break;
731 731
 			}
732
-        }
733
-        return false;
734
-    }
735
-
736
-    /**
737
-     * Make sure administrators can see Formidable menu
738
-     *
739
-     * @since 2.0
740
-     */
741
-    public static function maybe_add_permissions() {
732
+		}
733
+		return false;
734
+	}
735
+
736
+	/**
737
+	 * Make sure administrators can see Formidable menu
738
+	 *
739
+	 * @since 2.0
740
+	 */
741
+	public static function maybe_add_permissions() {
742 742
 		self::force_capability( 'frm_view_entries' );
743 743
 
744 744
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -747,12 +747,12 @@  discard block
 block discarded – undo
747 747
 
748 748
 		$user_id = get_current_user_id();
749 749
 		$user = new WP_User( $user_id );
750
-        $frm_roles = self::frm_capabilities();
751
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
750
+		$frm_roles = self::frm_capabilities();
751
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
752 752
 			$user->add_cap( $frm_role );
753 753
 			unset( $frm_role, $frm_role_description );
754
-        }
755
-    }
754
+		}
755
+	}
756 756
 
757 757
 	/**
758 758
 	 * Make sure admins have permission to see the menu items
@@ -768,28 +768,28 @@  discard block
 block discarded – undo
768 768
 		}
769 769
 	}
770 770
 
771
-    /**
772
-     * Check if the user has permision for action.
773
-     * Return permission message and stop the action if no permission
774
-     * @since 2.0
775
-     * @param string $permission
776
-     */
771
+	/**
772
+	 * Check if the user has permision for action.
773
+	 * Return permission message and stop the action if no permission
774
+	 * @since 2.0
775
+	 * @param string $permission
776
+	 */
777 777
 	public static function permission_check( $permission, $show_message = 'show' ) {
778 778
 		$permission_error = self::permission_nonce_error( $permission );
779
-        if ( $permission_error !== false ) {
780
-            if ( 'hide' == $show_message ) {
781
-                $permission_error = '';
782
-            }
779
+		if ( $permission_error !== false ) {
780
+			if ( 'hide' == $show_message ) {
781
+				$permission_error = '';
782
+			}
783 783
 			wp_die( esc_html( $permission_error ) );
784
-        }
785
-    }
786
-
787
-    /**
788
-     * Check user permission and nonce
789
-     * @since 2.0
790
-     * @param string $permission
791
-     * @return false|string The permission message or false if allowed
792
-     */
784
+		}
785
+	}
786
+
787
+	/**
788
+	 * Check user permission and nonce
789
+	 * @since 2.0
790
+	 * @param string $permission
791
+	 * @return false|string The permission message or false if allowed
792
+	 */
793 793
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
794 794
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
795 795
 			$frm_settings = self::get_settings();
@@ -798,22 +798,22 @@  discard block
 block discarded – undo
798 798
 
799 799
 		$error = false;
800 800
 		if ( empty( $nonce_name ) ) {
801
-            return $error;
802
-        }
801
+			return $error;
802
+		}
803 803
 
804
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
805
-            $frm_settings = self::get_settings();
806
-            $error = $frm_settings->admin_permission;
807
-        }
804
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
805
+			$frm_settings = self::get_settings();
806
+			$error = $frm_settings->admin_permission;
807
+		}
808 808
 
809
-        return $error;
810
-    }
809
+		return $error;
810
+	}
811 811
 
812
-    public static function checked( $values, $current ) {
812
+	public static function checked( $values, $current ) {
813 813
 		if ( self::check_selected( $values, $current ) ) {
814
-            echo ' checked="checked"';
814
+			echo ' checked="checked"';
815 815
 		}
816
-    }
816
+	}
817 817
 
818 818
 	public static function check_selected( $values, $current ) {
819 819
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -851,24 +851,24 @@  discard block
 block discarded – undo
851 851
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
852 852
 	}
853 853
 
854
-    /**
855
-     * Flatten a multi-dimensional array
856
-     */
854
+	/**
855
+	 * Flatten a multi-dimensional array
856
+	 */
857 857
 	public static function array_flatten( $array, $keys = 'keep' ) {
858
-        $return = array();
859
-        foreach ( $array as $key => $value ) {
858
+		$return = array();
859
+		foreach ( $array as $key => $value ) {
860 860
 			if ( is_array( $value ) ) {
861 861
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
862
-            } else {
862
+			} else {
863 863
 				if ( $keys == 'keep' ) {
864 864
 					$return[ $key ] = $value;
865 865
 				} else {
866 866
 					$return[] = $value;
867 867
 				}
868
-            }
869
-        }
870
-        return $return;
871
-    }
868
+			}
869
+		}
870
+		return $return;
871
+	}
872 872
 
873 873
 	public static function esc_textarea( $text, $is_rich_text = false ) {
874 874
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -879,10 +879,10 @@  discard block
 block discarded – undo
879 879
 		return apply_filters( 'esc_textarea', $safe_text, $text );
880 880
 	}
881 881
 
882
-    /**
883
-     * Add auto paragraphs to text areas
884
-     * @since 2.0
885
-     */
882
+	/**
883
+	 * Add auto paragraphs to text areas
884
+	 * @since 2.0
885
+	 */
886 886
 	public static function use_wpautop( $content ) {
887 887
 		if ( apply_filters( 'frm_use_wpautop', true ) ) {
888 888
 			$content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -891,26 +891,26 @@  discard block
 block discarded – undo
891 891
 	}
892 892
 
893 893
 	public static function replace_quotes( $val ) {
894
-        //Replace double quotes
894
+		//Replace double quotes
895 895
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
896
-        //Replace single quotes
897
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
898
-        return $val;
899
-    }
900
-
901
-    /**
902
-     * @since 2.0
903
-     * @return string The base Google APIS url for the current version of jQuery UI
904
-     */
905
-    public static function jquery_ui_base_url() {
896
+		//Replace single quotes
897
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
898
+		return $val;
899
+	}
900
+
901
+	/**
902
+	 * @since 2.0
903
+	 * @return string The base Google APIS url for the current version of jQuery UI
904
+	 */
905
+	public static function jquery_ui_base_url() {
906 906
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
907 907
 		$url = apply_filters( 'frm_jquery_ui_base_url', $url );
908
-        return $url;
909
-    }
908
+		return $url;
909
+	}
910 910
 
911
-    /**
912
-     * @param string $handle
913
-     */
911
+	/**
912
+	 * @param string $handle
913
+	 */
914 914
 	public static function script_version( $handle, $default = 0 ) {
915 915
 		global $wp_scripts;
916 916
 		if ( ! $wp_scripts ) {
@@ -932,12 +932,12 @@  discard block
 block discarded – undo
932 932
 
933 933
 	public static function js_redirect( $url ) {
934 934
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
935
-    }
935
+	}
936 936
 
937 937
 	public static function get_user_id_param( $user_id ) {
938 938
 		if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
939
-            return $user_id;
940
-        }
939
+			return $user_id;
940
+		}
941 941
 
942 942
 		$user_id = sanitize_text_field( $user_id );
943 943
 		if ( $user_id == 'current' ) {
@@ -949,14 +949,14 @@  discard block
 block discarded – undo
949 949
 				$user = get_user_by( 'login', $user_id );
950 950
 			}
951 951
 
952
-            if ( $user ) {
953
-                $user_id = $user->ID;
954
-            }
952
+			if ( $user ) {
953
+				$user_id = $user->ID;
954
+			}
955 955
 			unset( $user );
956
-        }
956
+		}
957 957
 
958
-        return $user_id;
959
-    }
958
+		return $user_id;
959
+	}
960 960
 
961 961
 	public static function get_file_contents( $filename, $atts = array() ) {
962 962
 		if ( ! is_file( $filename ) ) {
@@ -971,28 +971,28 @@  discard block
 block discarded – undo
971 971
 		return $contents;
972 972
 	}
973 973
 
974
-    /**
975
-     * @param string $table_name
976
-     * @param string $column
974
+	/**
975
+	 * @param string $table_name
976
+	 * @param string $column
977 977
 	 * @param int $id
978 978
 	 * @param int $num_chars
979
-     */
980
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
981
-        $key = '';
979
+	 */
980
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
981
+		$key = '';
982 982
 
983
-        if ( ! empty( $name ) ) {
983
+		if ( ! empty( $name ) ) {
984 984
 			$key = sanitize_key( $name );
985
-        }
985
+		}
986 986
 
987 987
 		if ( empty( $key ) ) {
988 988
 			$max_slug_value = pow( 36, $num_chars );
989
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
989
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
990 990
 			$key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
991
-        }
991
+		}
992 992
 
993 993
 		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
994 994
 			$key = $key . 'a';
995
-        }
995
+		}
996 996
 
997 997
 		$key_check = FrmDb::get_var(
998 998
 			$table_name,
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 		);
1005 1005
 
1006 1006
 		if ( $key_check || is_numeric( $key_check ) ) {
1007
-            $suffix = 2;
1007
+			$suffix = 2;
1008 1008
 			do {
1009 1009
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1010 1010
 				$key_check = FrmDb::get_var(
@@ -1018,19 +1018,19 @@  discard block
 block discarded – undo
1018 1018
 				$suffix++;
1019 1019
 			} while ( $key_check || is_numeric( $key_check ) );
1020 1020
 			$key = $alt_post_name;
1021
-        }
1022
-        return $key;
1023
-    }
1024
-
1025
-    /**
1026
-     * Editing a Form or Entry
1027
-     * @param string $table
1028
-     * @return bool|array
1029
-     */
1030
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1031
-        if ( ! $record ) {
1032
-            return false;
1033
-        }
1021
+		}
1022
+		return $key;
1023
+	}
1024
+
1025
+	/**
1026
+	 * Editing a Form or Entry
1027
+	 * @param string $table
1028
+	 * @return bool|array
1029
+	 */
1030
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1031
+		if ( ! $record ) {
1032
+			return false;
1033
+		}
1034 1034
 
1035 1035
 		if ( empty( $post_values ) ) {
1036 1036
 			$post_values = stripslashes_deep( $_POST );
@@ -1053,14 +1053,14 @@  discard block
 block discarded – undo
1053 1053
 
1054 1054
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1055 1055
 
1056
-        if ( $table == 'entries' ) {
1057
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1058
-        } else if ( $table == 'forms' ) {
1059
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1060
-        }
1056
+		if ( $table == 'entries' ) {
1057
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1058
+		} else if ( $table == 'forms' ) {
1059
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1060
+		}
1061 1061
 
1062
-        return $values;
1063
-    }
1062
+		return $values;
1063
+	}
1064 1064
 
1065 1065
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1066 1066
 		if ( ! empty( $fields ) ) {
@@ -1073,15 +1073,15 @@  discard block
 block discarded – undo
1073 1073
 	}
1074 1074
 
1075 1075
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1076
-        $post_values = $args['post_values'];
1076
+		$post_values = $args['post_values'];
1077 1077
 
1078
-        if ( $args['default'] ) {
1079
-            $meta_value = $field->default_value;
1080
-        } else {
1078
+		if ( $args['default'] ) {
1079
+			$meta_value = $field->default_value;
1080
+		} else {
1081 1081
 			if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1082 1082
 				if ( ! isset( $field->field_options['custom_field'] ) ) {
1083
-                    $field->field_options['custom_field'] = '';
1084
-                }
1083
+					$field->field_options['custom_field'] = '';
1084
+				}
1085 1085
 				$meta_value = FrmProEntryMetaHelper::get_post_value(
1086 1086
 					$record->post_id,
1087 1087
 					$field->field_options['post_field'],
@@ -1093,31 +1093,31 @@  discard block
 block discarded – undo
1093 1093
 						'field' => $field,
1094 1094
 					)
1095 1095
 				);
1096
-            } else {
1096
+			} else {
1097 1097
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1098
-            }
1099
-        }
1098
+			}
1099
+		}
1100 1100
 
1101 1101
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1102
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1102
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1103 1103
 
1104 1104
 		$field_array = self::start_field_array( $field );
1105 1105
 		$field_array['value'] = $new_value;
1106 1106
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1107 1107
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1108 1108
 
1109
-        $args['field_type'] = $field_type;
1109
+		$args['field_type'] = $field_type;
1110 1110
 
1111 1111
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1112 1112
 
1113 1113
 		if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1114
-            $field_array['unique_msg'] = '';
1115
-        }
1114
+			$field_array['unique_msg'] = '';
1115
+		}
1116 1116
 
1117
-        $field_array = array_merge( $field->field_options, $field_array );
1117
+		$field_array = array_merge( $field->field_options, $field_array );
1118 1118
 
1119
-        $values['fields'][ $field->id ] = $field_array;
1120
-    }
1119
+		$values['fields'][ $field->id ] = $field_array;
1120
+	}
1121 1121
 
1122 1122
 	/**
1123 1123
 	 * @since 3.0
@@ -1138,20 +1138,20 @@  discard block
 block discarded – undo
1138 1138
 		);
1139 1139
 	}
1140 1140
 
1141
-    /**
1142
-     * @param string $table
1143
-     */
1141
+	/**
1142
+	 * @param string $table
1143
+	 */
1144 1144
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1145
-        if ( $table == 'entries' ) {
1146
-            $form = $record->form_id;
1145
+		if ( $table == 'entries' ) {
1146
+			$form = $record->form_id;
1147 1147
 			FrmForm::maybe_get_form( $form );
1148
-        } else {
1149
-            $form = $record;
1150
-        }
1148
+		} else {
1149
+			$form = $record;
1150
+		}
1151 1151
 
1152
-        if ( ! $form ) {
1153
-            return;
1154
-        }
1152
+		if ( ! $form ) {
1153
+			return;
1154
+		}
1155 1155
 
1156 1156
 		$values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1157 1157
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
@@ -1160,26 +1160,26 @@  discard block
 block discarded – undo
1160 1160
 			return;
1161 1161
 		}
1162 1162
 
1163
-        foreach ( $form->options as $opt => $value ) {
1164
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1165
-        }
1163
+		foreach ( $form->options as $opt => $value ) {
1164
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1165
+		}
1166 1166
 
1167 1167
 		self::fill_form_defaults( $post_values, $values );
1168
-    }
1168
+	}
1169 1169
 
1170
-    /**
1171
-     * Set to POST value or default
1172
-     */
1170
+	/**
1171
+	 * Set to POST value or default
1172
+	 */
1173 1173
 	private static function fill_form_defaults( $post_values, array &$values ) {
1174
-        $form_defaults = FrmFormsHelper::get_default_opts();
1174
+		$form_defaults = FrmFormsHelper::get_default_opts();
1175 1175
 
1176
-        foreach ( $form_defaults as $opt => $default ) {
1177
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1176
+		foreach ( $form_defaults as $opt => $default ) {
1177
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1178 1178
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1179
-            }
1179
+			}
1180 1180
 
1181 1181
 			unset( $opt, $default );
1182
-        }
1182
+		}
1183 1183
 
1184 1184
 		if ( ! isset( $values['custom_style'] ) ) {
1185 1185
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1188,10 +1188,10 @@  discard block
 block discarded – undo
1188 1188
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1189 1189
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1190 1190
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1191
-            }
1191
+			}
1192 1192
 			unset( $h );
1193
-        }
1194
-    }
1193
+		}
1194
+	}
1195 1195
 
1196 1196
 	/**
1197 1197
 	 * @since 2.2.10
@@ -1214,33 +1214,33 @@  discard block
 block discarded – undo
1214 1214
 		if ( $possible_email_field ) {
1215 1215
 			$class .= 'show_frm_not_email_to';
1216 1216
 		}
1217
-    ?>
1217
+	?>
1218 1218
 <li>
1219 1219
 	<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>
1220 1220
 	<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>
1221 1221
 	<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>
1222 1222
 </li>
1223 1223
     <?php
1224
-    }
1224
+	}
1225 1225
 
1226 1226
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1227
-        if ( is_array( $str ) ) {
1228
-            return '';
1227
+		if ( is_array( $str ) ) {
1228
+			return '';
1229 1229
 		}
1230 1230
 
1231
-        $length = (int) $length;
1231
+		$length = (int) $length;
1232 1232
 		$str = wp_strip_all_tags( $str );
1233 1233
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1234 1234
 
1235 1235
 		if ( $length == 0 ) {
1236
-            return '';
1237
-        } else if ( $length <= 10 ) {
1236
+			return '';
1237
+		} else if ( $length <= 10 ) {
1238 1238
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1239 1239
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1240
-        }
1240
+		}
1241 1241
 
1242
-        $sub = '';
1243
-        $len = 0;
1242
+		$sub = '';
1243
+		$len = 0;
1244 1244
 
1245 1245
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1246 1246
 
@@ -1248,21 +1248,21 @@  discard block
 block discarded – undo
1248 1248
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1249 1249
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1250 1250
 			if ( $total_len > $length && str_word_count( $sub ) ) {
1251
-                break;
1252
-            }
1251
+				break;
1252
+			}
1253 1253
 
1254
-            $sub .= $part;
1254
+			$sub .= $part;
1255 1255
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1256 1256
 
1257 1257
 			if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1258
-                break;
1259
-            }
1258
+				break;
1259
+			}
1260 1260
 
1261 1261
 			unset( $total_len, $word );
1262
-        }
1262
+		}
1263 1263
 
1264 1264
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1265
-    }
1265
+	}
1266 1266
 
1267 1267
 	public static function mb_function( $function_names, $args ) {
1268 1268
 		$mb_function_name = $function_names[0];
@@ -1275,17 +1275,17 @@  discard block
 block discarded – undo
1275 1275
 
1276 1276
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1277 1277
 		if ( empty( $date ) ) {
1278
-            return $date;
1279
-        }
1278
+			return $date;
1279
+		}
1280 1280
 
1281 1281
 		if ( empty( $date_format ) ) {
1282 1282
 			$date_format = get_option( 'date_format' );
1283 1283
 		}
1284 1284
 
1285 1285
 		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1286
-            $frmpro_settings = new FrmProSettings();
1286
+			$frmpro_settings = new FrmProSettings();
1287 1287
 			$date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1288
-        }
1288
+		}
1289 1289
 
1290 1290
 		$formatted = self::get_localized_date( $date_format, $date );
1291 1291
 
@@ -1294,8 +1294,8 @@  discard block
 block discarded – undo
1294 1294
 			$formatted .= self::add_time_to_date( $time_format, $date );
1295 1295
 		}
1296 1296
 
1297
-        return $formatted;
1298
-    }
1297
+		return $formatted;
1298
+	}
1299 1299
 
1300 1300
 	private static function add_time_to_date( $time_format, $date ) {
1301 1301
 		if ( empty( $time_format ) ) {
@@ -1377,32 +1377,32 @@  discard block
 block discarded – undo
1377 1377
 		);
1378 1378
 	}
1379 1379
 
1380
-    // Pagination Methods
1380
+	// Pagination Methods
1381 1381
 
1382
-    /**
1383
-     * @param integer $current_p
1384
-     */
1382
+	/**
1383
+	 * @param integer $current_p
1384
+	 */
1385 1385
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1386 1386
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1387 1387
 	}
1388 1388
 
1389
-    /**
1390
-     * @param integer $current_p
1391
-     */
1392
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1393
-        if ( $current_p == 1 ) {
1394
-            return 1;
1395
-        } else {
1396
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1397
-        }
1398
-    }
1389
+	/**
1390
+	 * @param integer $current_p
1391
+	 */
1392
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1393
+		if ( $current_p == 1 ) {
1394
+			return 1;
1395
+		} else {
1396
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1397
+		}
1398
+	}
1399 1399
 
1400 1400
 	/**
1401 1401
 	 * @return array
1402 1402
 	 */
1403 1403
 	public static function json_to_array( $json_vars ) {
1404
-        $vars = array();
1405
-        foreach ( $json_vars as $jv ) {
1404
+		$vars = array();
1405
+		foreach ( $json_vars as $jv ) {
1406 1406
 			$jv_name = explode( '[', $jv['name'] );
1407 1407
 			$last = count( $jv_name ) - 1;
1408 1408
 			foreach ( $jv_name as $p => $n ) {
@@ -1419,77 +1419,77 @@  discard block
 block discarded – undo
1419 1419
 					$l3 = $name;
1420 1420
 				}
1421 1421
 
1422
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1422
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1423 1423
 
1424
-                switch ( $p ) {
1425
-                    case 0:
1426
-                        $l1 = $name;
1427
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1424
+				switch ( $p ) {
1425
+					case 0:
1426
+						$l1 = $name;
1427
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1428 1428
 						break;
1429 1429
 
1430
-                    case 1:
1431
-                        $l2 = $name;
1432
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1430
+					case 1:
1431
+						$l2 = $name;
1432
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1433 1433
 						break;
1434 1434
 
1435
-                    case 2:
1436
-                        $l3 = $name;
1437
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1435
+					case 2:
1436
+						$l3 = $name;
1437
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1438 1438
 						break;
1439 1439
 
1440
-                    case 3:
1441
-                        $l4 = $name;
1442
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1443
-                }
1440
+					case 3:
1441
+						$l4 = $name;
1442
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1443
+				}
1444 1444
 
1445 1445
 				unset( $this_val, $n );
1446
-            }
1446
+			}
1447 1447
 
1448 1448
 			unset( $last, $jv );
1449
-        }
1450
-
1451
-        return $vars;
1452
-    }
1453
-
1454
-    /**
1455
-     * @param string $name
1456
-     * @param string $l1
1457
-     */
1458
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1459
-        if ( $name == '' ) {
1460
-            $vars[] = $val;
1461
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1462
-            $vars[ $l1 ] = $val;
1463
-        }
1464
-    }
1449
+		}
1450
+
1451
+		return $vars;
1452
+	}
1453
+
1454
+	/**
1455
+	 * @param string $name
1456
+	 * @param string $l1
1457
+	 */
1458
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1459
+		if ( $name == '' ) {
1460
+			$vars[] = $val;
1461
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1462
+			$vars[ $l1 ] = $val;
1463
+		}
1464
+	}
1465 1465
 
1466 1466
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1467
-        $tooltips = array(
1468
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1469
-            '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' ),
1470
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1471
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1472
-            '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' ),
1473
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1474
-            '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() ) ),
1475
-        );
1476
-
1477
-        if ( ! isset( $tooltips[ $name ] ) ) {
1478
-            return;
1479
-        }
1480
-
1481
-        if ( 'open' == $class ) {
1482
-            echo ' frm_help"';
1483
-        } else {
1484
-            echo ' class="frm_help"';
1485
-        }
1467
+		$tooltips = array(
1468
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1469
+			'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' ),
1470
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1471
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1472
+			'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' ),
1473
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1474
+			'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() ) ),
1475
+		);
1476
+
1477
+		if ( ! isset( $tooltips[ $name ] ) ) {
1478
+			return;
1479
+		}
1480
+
1481
+		if ( 'open' == $class ) {
1482
+			echo ' frm_help"';
1483
+		} else {
1484
+			echo ' class="frm_help"';
1485
+		}
1486 1486
 
1487 1487
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1488 1488
 
1489
-        if ( 'open' != $class ) {
1490
-            echo '"';
1491
-        }
1492
-    }
1489
+		if ( 'open' != $class ) {
1490
+			echo '"';
1491
+		}
1492
+	}
1493 1493
 
1494 1494
 	/**
1495 1495
 	 * Add the current_page class to that page in the form nav
@@ -1505,35 +1505,35 @@  discard block
 block discarded – undo
1505 1505
 		}
1506 1506
 	}
1507 1507
 
1508
-    /**
1509
-     * Prepare and json_encode post content
1510
-     *
1511
-     * @since 2.0
1512
-     *
1513
-     * @param array $post_content
1514
-     * @return string $post_content ( json encoded array )
1515
-     */
1516
-    public static function prepare_and_encode( $post_content ) {
1517
-        //Loop through array to strip slashes and add only the needed ones
1508
+	/**
1509
+	 * Prepare and json_encode post content
1510
+	 *
1511
+	 * @since 2.0
1512
+	 *
1513
+	 * @param array $post_content
1514
+	 * @return string $post_content ( json encoded array )
1515
+	 */
1516
+	public static function prepare_and_encode( $post_content ) {
1517
+		//Loop through array to strip slashes and add only the needed ones
1518 1518
 		foreach ( $post_content as $key => $val ) {
1519 1519
 			// Replace problematic characters (like &quot;)
1520 1520
 			$val = str_replace( '&quot;', '"', $val );
1521 1521
 
1522 1522
 			self::prepare_action_slashes( $val, $key, $post_content );
1523
-            unset( $key, $val );
1524
-        }
1523
+			unset( $key, $val );
1524
+		}
1525 1525
 
1526
-        // json_encode the array
1527
-        $post_content = json_encode( $post_content );
1526
+		// json_encode the array
1527
+		$post_content = json_encode( $post_content );
1528 1528
 
1529
-	    // add extra slashes for \r\n since WP strips them
1529
+		// add extra slashes for \r\n since WP strips them
1530 1530
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1531 1531
 
1532
-        // allow for &quot
1533
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1532
+		// allow for &quot
1533
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1534 1534
 
1535
-        return $post_content;
1536
-    }
1535
+		return $post_content;
1536
+	}
1537 1537
 
1538 1538
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1539 1539
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1556,54 +1556,54 @@  discard block
 block discarded – undo
1556 1556
 
1557 1557
 	public static function maybe_json_decode( $string ) {
1558 1558
 		if ( is_array( $string ) ) {
1559
-            return $string;
1560
-        }
1559
+			return $string;
1560
+		}
1561 1561
 
1562 1562
 		$new_string = json_decode( $string, true );
1563 1563
 		if ( function_exists( 'json_last_error' ) ) {
1564 1564
 			// php 5.3+
1565
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1566
-                $string = $new_string;
1567
-            }
1565
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1566
+				$string = $new_string;
1567
+			}
1568 1568
 		} elseif ( isset( $new_string ) ) {
1569 1569
 			// php < 5.3 fallback
1570
-            $string = $new_string;
1571
-        }
1572
-        return $string;
1573
-    }
1574
-
1575
-    /**
1576
-     * @since 1.07.10
1577
-     *
1578
-     * @param string $post_type The name of the post type that may need to be highlighted
1579
-     * echo The javascript to open and highlight the Formidable menu
1580
-     */
1570
+			$string = $new_string;
1571
+		}
1572
+		return $string;
1573
+	}
1574
+
1575
+	/**
1576
+	 * @since 1.07.10
1577
+	 *
1578
+	 * @param string $post_type The name of the post type that may need to be highlighted
1579
+	 * echo The javascript to open and highlight the Formidable menu
1580
+	 */
1581 1581
 	public static function maybe_highlight_menu( $post_type ) {
1582
-        global $post;
1582
+		global $post;
1583 1583
 
1584 1584
 		if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1585
-            return;
1586
-        }
1585
+			return;
1586
+		}
1587 1587
 
1588 1588
 		if ( is_object( $post ) && $post->post_type != $post_type ) {
1589
-            return;
1590
-        }
1589
+			return;
1590
+		}
1591 1591
 
1592
-        self::load_admin_wide_js();
1593
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1594
-    }
1592
+		self::load_admin_wide_js();
1593
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1594
+	}
1595 1595
 
1596
-    /**
1597
-     * Load the JS file on non-Formidable pages in the admin area
1598
-     * @since 2.0
1599
-     */
1596
+	/**
1597
+	 * Load the JS file on non-Formidable pages in the admin area
1598
+	 * @since 2.0
1599
+	 */
1600 1600
 	public static function load_admin_wide_js( $load = true ) {
1601
-        $version = FrmAppHelper::plugin_version();
1601
+		$version = FrmAppHelper::plugin_version();
1602 1602
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1603 1603
 
1604 1604
 		$global_strings = array(
1605 1605
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1606
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1606
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1607 1607
 			'url'          => FrmAppHelper::plugin_url(),
1608 1608
 			'loading'      => __( 'Loading&hellip;' ),
1609 1609
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 		if ( $load ) {
1614 1614
 			wp_enqueue_script( 'formidable_admin_global' );
1615 1615
 		}
1616
-    }
1616
+	}
1617 1617
 
1618 1618
 	/**
1619 1619
 	 * @since 2.0.9
@@ -1622,9 +1622,9 @@  discard block
 block discarded – undo
1622 1622
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1623 1623
 	}
1624 1624
 
1625
-    /**
1626
-     * @param string $location
1627
-     */
1625
+	/**
1626
+	 * @param string $location
1627
+	 */
1628 1628
 	public static function localize_script( $location ) {
1629 1629
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1630 1630
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1687,27 +1687,27 @@  discard block
 block discarded – undo
1687 1687
 		}
1688 1688
 	}
1689 1689
 
1690
-    /**
1690
+	/**
1691 1691
 	 * echo the message on the plugins listing page
1692
-     * @since 1.07.10
1693
-     *
1694
-     * @param float $min_version The version the add-on requires
1695
-     */
1692
+	 * @since 1.07.10
1693
+	 *
1694
+	 * @param float $min_version The version the add-on requires
1695
+	 */
1696 1696
 	public static function min_version_notice( $min_version ) {
1697
-        $frm_version = self::plugin_version();
1697
+		$frm_version = self::plugin_version();
1698 1698
 
1699
-        // check if Formidable meets minimum requirements
1699
+		// check if Formidable meets minimum requirements
1700 1700
 		if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1701
-            return;
1702
-        }
1701
+			return;
1702
+		}
1703 1703
 
1704 1704
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1705 1705
 		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">' .
1706
-        esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1707
-        '</div></td></tr>';
1708
-    }
1706
+		esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1707
+		'</div></td></tr>';
1708
+	}
1709 1709
 
1710
-    public static function locales( $type = 'date' ) {
1710
+	public static function locales( $type = 'date' ) {
1711 1711
 		$locales = array(
1712 1712
 			'en' => __( 'English', 'formidable' ),
1713 1713
 			''   => __( 'English/Western', 'formidable' ),
@@ -1786,8 +1786,8 @@  discard block
 block discarded – undo
1786 1786
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1787 1787
 		$locales = apply_filters( 'frm_locales', $locales );
1788 1788
 
1789
-        return $locales;
1790
-    }
1789
+		return $locales;
1790
+	}
1791 1791
 
1792 1792
 	/**
1793 1793
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.