Completed
Push — master ( f50457...458dfc )
by Stephanie
03:14
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +548 added lines, -548 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.06';
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
 	}
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 		return add_query_arg( $query_args, $page );
89 89
 	}
90 90
 
91
-    /**
92
-     * Get the Formidable settings
93
-     *
94
-     * @since 2.0
95
-     *
96
-     * @param None
97
-     * @return FrmSettings $frm_setings
98
-     */
91
+	/**
92
+	 * Get the Formidable settings
93
+	 *
94
+	 * @since 2.0
95
+	 *
96
+	 * @param None
97
+	 * @return FrmSettings $frm_setings
98
+	 */
99 99
 	public static function get_settings() {
100 100
 		global $frm_settings;
101 101
 		if ( empty( $frm_settings ) ) {
@@ -156,50 +156,50 @@  discard block
 block discarded – undo
156 156
 		return $is_formidable;
157 157
 	}
158 158
 
159
-    /**
160
-     * Check for certain page in Formidable settings
161
-     *
162
-     * @since 2.0
163
-     *
164
-     * @param string $page The name of the page to check
165
-     * @return boolean
166
-     */
159
+	/**
160
+	 * Check for certain page in Formidable settings
161
+	 *
162
+	 * @since 2.0
163
+	 *
164
+	 * @param string $page The name of the page to check
165
+	 * @return boolean
166
+	 */
167 167
 	public static function is_admin_page( $page = 'formidable' ) {
168
-        global $pagenow;
168
+		global $pagenow;
169 169
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
170
-        if ( $pagenow ) {
170
+		if ( $pagenow ) {
171 171
 			// allow this to be true during ajax load i.e. ajax form builder loading
172 172
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
173
-        }
173
+		}
174 174
 
175 175
 		return is_admin() && $get_page == $page;
176
-    }
177
-
178
-    /**
179
-     * Check for the form preview page
180
-     *
181
-     * @since 2.0
182
-     *
183
-     * @param None
184
-     * @return boolean
185
-     */
186
-    public static function is_preview_page() {
187
-        global $pagenow;
176
+	}
177
+
178
+	/**
179
+	 * Check for the form preview page
180
+	 *
181
+	 * @since 2.0
182
+	 *
183
+	 * @param None
184
+	 * @return boolean
185
+	 */
186
+	public static function is_preview_page() {
187
+		global $pagenow;
188 188
 		$action = self::simple_get( 'action', 'sanitize_title' );
189 189
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
190
-    }
191
-
192
-    /**
193
-     * Check for ajax except the form preview page
194
-     *
195
-     * @since 2.0
196
-     *
197
-     * @param None
198
-     * @return boolean
199
-     */
200
-    public static function doing_ajax() {
201
-        return self::wp_doing_ajax() && ! self::is_preview_page();
202
-    }
190
+	}
191
+
192
+	/**
193
+	 * Check for ajax except the form preview page
194
+	 *
195
+	 * @since 2.0
196
+	 *
197
+	 * @param None
198
+	 * @return boolean
199
+	 */
200
+	public static function doing_ajax() {
201
+		return self::wp_doing_ajax() && ! self::is_preview_page();
202
+	}
203 203
 
204 204
 	public static function js_suffix() {
205 205
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -227,81 +227,81 @@  discard block
 block discarded – undo
227 227
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
228 228
 	}
229 229
 
230
-    /**
231
-     * Check if on an admin page
232
-     *
233
-     * @since 2.0
234
-     *
235
-     * @param None
236
-     * @return boolean
237
-     */
238
-    public static function is_admin() {
239
-        return is_admin() && ! self::wp_doing_ajax();
240
-    }
241
-
242
-    /**
243
-     * Check if value contains blank value or empty array
244
-     *
245
-     * @since 2.0
246
-     * @param mixed $value - value to check
230
+	/**
231
+	 * Check if on an admin page
232
+	 *
233
+	 * @since 2.0
234
+	 *
235
+	 * @param None
236
+	 * @return boolean
237
+	 */
238
+	public static function is_admin() {
239
+		return is_admin() && ! self::wp_doing_ajax();
240
+	}
241
+
242
+	/**
243
+	 * Check if value contains blank value or empty array
244
+	 *
245
+	 * @since 2.0
246
+	 * @param mixed $value - value to check
247 247
 	 * @param string
248
-     * @return boolean
249
-     */
250
-    public static function is_empty_value( $value, $empty = '' ) {
251
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
252
-    }
253
-
254
-    public static function is_not_empty_value( $value, $empty = '' ) {
255
-        return ! self::is_empty_value( $value, $empty );
256
-    }
257
-
258
-    /**
259
-     * Get any value from the $_SERVER
260
-     *
261
-     * @since 2.0
262
-     * @param string $value
263
-     * @return string
264
-     */
248
+	 * @return boolean
249
+	 */
250
+	public static function is_empty_value( $value, $empty = '' ) {
251
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
252
+	}
253
+
254
+	public static function is_not_empty_value( $value, $empty = '' ) {
255
+		return ! self::is_empty_value( $value, $empty );
256
+	}
257
+
258
+	/**
259
+	 * Get any value from the $_SERVER
260
+	 *
261
+	 * @since 2.0
262
+	 * @param string $value
263
+	 * @return string
264
+	 */
265 265
 	public static function get_server_value( $value ) {
266
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
267
-    }
268
-
269
-    /**
270
-     * Check for the IP address in several places
271
-     * Used by [ip] shortcode
272
-     *
273
-     * @return string The IP address of the current user
274
-     */
275
-    public static function get_ip_address() {
266
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
267
+	}
268
+
269
+	/**
270
+	 * Check for the IP address in several places
271
+	 * Used by [ip] shortcode
272
+	 *
273
+	 * @return string The IP address of the current user
274
+	 */
275
+	public static function get_ip_address() {
276 276
 		$ip = '';
277 277
 		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 ) {
278
-            if ( ! isset( $_SERVER[ $key ] ) ) {
279
-                continue;
280
-            }
278
+			if ( ! isset( $_SERVER[ $key ] ) ) {
279
+				continue;
280
+			}
281 281
 
282
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
282
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
283 283
 				$ip = trim( $ip ); // just to be safe
284 284
 
285 285
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
286
-                    return sanitize_text_field( $ip );
287
-                }
288
-            }
289
-        }
286
+					return sanitize_text_field( $ip );
287
+				}
288
+			}
289
+		}
290 290
 
291 291
 		return sanitize_text_field( $ip );
292
-    }
292
+	}
293 293
 
294
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
294
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
295 295
 		if ( strpos( $param, '[' ) ) {
296 296
 			$params = explode( '[', $param );
297
-            $param = $params[0];
298
-        }
297
+			$param = $params[0];
298
+		}
299 299
 
300 300
 		if ( $src == 'get' ) {
301
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
302
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
303
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
304
-            }
301
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
302
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
303
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
304
+			}
305 305
 			self::sanitize_value( $sanitize, $value );
306 306
 		} else {
307 307
 			$value = self::get_simple_request(
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 			}
326 326
 		}
327 327
 
328
-        return $value;
329
-    }
328
+		return $value;
329
+	}
330 330
 
331 331
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
332 332
 		return self::get_simple_request(
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
 	}
395 395
 
396 396
 	/**
397
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
398
-	*
399
-	* @since 2.0.8
400
-	* @param string $value
401
-	* @return string $value
402
-	*/
397
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
398
+	 *
399
+	 * @since 2.0.8
400
+	 * @param string $value
401
+	 * @return string $value
402
+	 */
403 403
 	public static function preserve_backslashes( $value ) {
404 404
 		// If backslashes have already been added, don't add them again
405 405
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
 		}
422 422
 	}
423 423
 
424
-    public static function sanitize_request( $sanitize_method, &$values ) {
425
-        $temp_values = $values;
426
-        foreach ( $temp_values as $k => $val ) {
427
-            if ( isset( $sanitize_method[ $k ] ) ) {
424
+	public static function sanitize_request( $sanitize_method, &$values ) {
425
+		$temp_values = $values;
426
+		foreach ( $temp_values as $k => $val ) {
427
+			if ( isset( $sanitize_method[ $k ] ) ) {
428 428
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
429
-            }
430
-        }
431
-    }
429
+			}
430
+		}
431
+	}
432 432
 
433 433
 	/**
434 434
 	 * Sanitize the value, and allow some HTML
@@ -565,40 +565,40 @@  discard block
 block discarded – undo
565 565
 		);
566 566
 	}
567 567
 
568
-    /**
569
-     * Used when switching the action for a bulk action
568
+	/**
569
+	 * Used when switching the action for a bulk action
570 570
 	 *
571
-     * @since 2.0
572
-     */
571
+	 * @since 2.0
572
+	 */
573 573
 	public static function remove_get_action() {
574 574
 		if ( ! isset( $_GET ) ) {
575 575
 			return;
576 576
 		}
577 577
 
578
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
579
-        if ( ! empty( $new_action ) ) {
578
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
579
+		if ( ! empty( $new_action ) ) {
580 580
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) );
581
-        }
582
-    }
581
+		}
582
+	}
583 583
 
584
-    /**
585
-     * Check the WP query for a parameter
586
-     *
587
-     * @since 2.0
588
-     * @return string|array
589
-     */
590
-    public static function get_query_var( $value, $param ) {
591
-        if ( $value != '' ) {
592
-            return $value;
593
-        }
584
+	/**
585
+	 * Check the WP query for a parameter
586
+	 *
587
+	 * @since 2.0
588
+	 * @return string|array
589
+	 */
590
+	public static function get_query_var( $value, $param ) {
591
+		if ( $value != '' ) {
592
+			return $value;
593
+		}
594 594
 
595
-        global $wp_query;
596
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
597
-            $value = $wp_query->query_vars[ $param ];
598
-        }
595
+		global $wp_query;
596
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
597
+			$value = $wp_query->query_vars[ $param ];
598
+		}
599 599
 
600
-        return $value;
601
-    }
600
+		return $value;
601
+	}
602 602
 
603 603
 	/**
604 604
 	 * @since 3.0
@@ -650,16 +650,16 @@  discard block
 block discarded – undo
650 650
 		<?php
651 651
 	}
652 652
 
653
-    /**
654
-     * @param string $type
655
-     */
656
-    public static function trigger_hook_load( $type, $object = null ) {
657
-        // only load the form hooks once
653
+	/**
654
+	 * @param string $type
655
+	 */
656
+	public static function trigger_hook_load( $type, $object = null ) {
657
+		// only load the form hooks once
658 658
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
659
-        if ( ! $hooks_loaded ) {
659
+		if ( ! $hooks_loaded ) {
660 660
 			do_action( 'frm_load_' . $type . '_hooks' );
661
-        }
662
-    }
661
+		}
662
+	}
663 663
 
664 664
 	/**
665 665
 	 * Save all front-end js scripts into a single file
@@ -684,18 +684,18 @@  discard block
 block discarded – undo
684 684
 		$new_file->combine_files( $files );
685 685
 	}
686 686
 
687
-    /**
688
-     * Check a value from a shortcode to see if true or false.
689
-     * True when value is 1, true, 'true', 'yes'
690
-     *
691
-     * @since 1.07.10
692
-     *
693
-     * @param string $value The value to compare
694
-     * @return boolean True or False
695
-     */
687
+	/**
688
+	 * Check a value from a shortcode to see if true or false.
689
+	 * True when value is 1, true, 'true', 'yes'
690
+	 *
691
+	 * @since 1.07.10
692
+	 *
693
+	 * @param string $value The value to compare
694
+	 * @return boolean True or False
695
+	 */
696 696
 	public static function is_true( $value ) {
697
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
698
-    }
697
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
698
+	}
699 699
 
700 700
 	public static function get_pages() {
701 701
 		$query = array(
@@ -708,10 +708,10 @@  discard block
 block discarded – undo
708 708
 		return get_posts( $query );
709 709
 	}
710 710
 
711
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
712
-        $pages = self::get_pages();
711
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
712
+		$pages = self::get_pages();
713 713
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
714
-    ?>
714
+	?>
715 715
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
716 716
             <option value=""> </option>
717 717
             <?php foreach ( $pages as $page ) { ?>
@@ -721,16 +721,16 @@  discard block
 block discarded – undo
721 721
             <?php } ?>
722 722
         </select>
723 723
     <?php
724
-    }
724
+	}
725 725
 
726 726
 	public static function post_edit_link( $post_id ) {
727 727
 		$post = get_post( $post_id );
728
-        if ( $post ) {
728
+		if ( $post ) {
729 729
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
730 730
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
731
-        }
732
-        return '';
733
-    }
731
+		}
732
+		return '';
733
+	}
734 734
 
735 735
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
736 736
 		?>
@@ -741,73 +741,73 @@  discard block
 block discarded – undo
741 741
 	}
742 742
 
743 743
 	public static function roles_options( $capability ) {
744
-        global $frm_vars;
744
+		global $frm_vars;
745 745
 		if ( isset( $frm_vars['editable_roles'] ) ) {
746
-            $editable_roles = $frm_vars['editable_roles'];
747
-        } else {
748
-            $editable_roles = get_editable_roles();
749
-            $frm_vars['editable_roles'] = $editable_roles;
750
-        }
746
+			$editable_roles = $frm_vars['editable_roles'];
747
+		} else {
748
+			$editable_roles = get_editable_roles();
749
+			$frm_vars['editable_roles'] = $editable_roles;
750
+		}
751 751
 
752
-        foreach ( $editable_roles as $role => $details ) {
752
+		foreach ( $editable_roles as $role => $details ) {
753 753
 			$name = translate_user_role( $details['name'] );
754 754
 			?>
755 755
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
756 756
 <?php
757 757
 			unset( $role, $details );
758
-        }
759
-    }
758
+		}
759
+	}
760 760
 
761 761
 	public static function frm_capabilities( $type = 'auto' ) {
762
-        $cap = array(
763
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
764
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
765
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
766
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
767
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
768
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
769
-        );
762
+		$cap = array(
763
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
764
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
765
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
766
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
767
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
768
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
769
+		);
770 770
 
771 771
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
772
-            return $cap;
773
-        }
772
+			return $cap;
773
+		}
774 774
 
775
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
776
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
777
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
778
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
775
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
776
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
777
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
778
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
779 779
 
780
-        return $cap;
781
-    }
780
+		return $cap;
781
+	}
782 782
 
783 783
 	public static function user_has_permission( $needed_role ) {
784
-        if ( $needed_role == '-1' ) {
785
-            return false;
784
+		if ( $needed_role == '-1' ) {
785
+			return false;
786 786
 		}
787 787
 
788
-        // $needed_role will be equal to blank if "Logged-in users" is selected
789
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
790
-            return true;
791
-        }
788
+		// $needed_role will be equal to blank if "Logged-in users" is selected
789
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
790
+			return true;
791
+		}
792 792
 
793
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
794
-        foreach ( $roles as $role ) {
793
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
794
+		foreach ( $roles as $role ) {
795 795
 			if ( current_user_can( $role ) ) {
796
-        		return true;
796
+				return true;
797 797
 			}
798
-        	if ( $role == $needed_role ) {
799
-        		break;
798
+			if ( $role == $needed_role ) {
799
+				break;
800 800
 			}
801
-        }
802
-        return false;
803
-    }
804
-
805
-    /**
806
-     * Make sure administrators can see Formidable menu
807
-     *
808
-     * @since 2.0
809
-     */
810
-    public static function maybe_add_permissions() {
801
+		}
802
+		return false;
803
+	}
804
+
805
+	/**
806
+	 * Make sure administrators can see Formidable menu
807
+	 *
808
+	 * @since 2.0
809
+	 */
810
+	public static function maybe_add_permissions() {
811 811
 		self::force_capability( 'frm_view_entries' );
812 812
 
813 813
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -816,12 +816,12 @@  discard block
 block discarded – undo
816 816
 
817 817
 		$user_id = get_current_user_id();
818 818
 		$user = new WP_User( $user_id );
819
-        $frm_roles = self::frm_capabilities();
820
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
819
+		$frm_roles = self::frm_capabilities();
820
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
821 821
 			$user->add_cap( $frm_role );
822 822
 			unset( $frm_role, $frm_role_description );
823
-        }
824
-    }
823
+		}
824
+	}
825 825
 
826 826
 	/**
827 827
 	 * Make sure admins have permission to see the menu items
@@ -838,30 +838,30 @@  discard block
 block discarded – undo
838 838
 		}
839 839
 	}
840 840
 
841
-    /**
842
-     * Check if the user has permision for action.
843
-     * Return permission message and stop the action if no permission
841
+	/**
842
+	 * Check if the user has permision for action.
843
+	 * Return permission message and stop the action if no permission
844 844
 	 *
845
-     * @since 2.0
846
-     * @param string $permission
847
-     */
845
+	 * @since 2.0
846
+	 * @param string $permission
847
+	 */
848 848
 	public static function permission_check( $permission, $show_message = 'show' ) {
849 849
 		$permission_error = self::permission_nonce_error( $permission );
850
-        if ( $permission_error !== false ) {
851
-            if ( 'hide' == $show_message ) {
852
-                $permission_error = '';
853
-            }
850
+		if ( $permission_error !== false ) {
851
+			if ( 'hide' == $show_message ) {
852
+				$permission_error = '';
853
+			}
854 854
 			wp_die( esc_html( $permission_error ) );
855
-        }
856
-    }
855
+		}
856
+	}
857 857
 
858
-    /**
859
-     * Check user permission and nonce
858
+	/**
859
+	 * Check user permission and nonce
860 860
 	 *
861
-     * @since 2.0
862
-     * @param string $permission
863
-     * @return false|string The permission message or false if allowed
864
-     */
861
+	 * @since 2.0
862
+	 * @param string $permission
863
+	 * @return false|string The permission message or false if allowed
864
+	 */
865 865
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
866 866
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
867 867
 			$frm_settings = self::get_settings();
@@ -870,22 +870,22 @@  discard block
 block discarded – undo
870 870
 
871 871
 		$error = false;
872 872
 		if ( empty( $nonce_name ) ) {
873
-            return $error;
874
-        }
873
+			return $error;
874
+		}
875 875
 
876
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
877
-            $frm_settings = self::get_settings();
878
-            $error = $frm_settings->admin_permission;
879
-        }
876
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
877
+			$frm_settings = self::get_settings();
878
+			$error = $frm_settings->admin_permission;
879
+		}
880 880
 
881
-        return $error;
882
-    }
881
+		return $error;
882
+	}
883 883
 
884
-    public static function checked( $values, $current ) {
884
+	public static function checked( $values, $current ) {
885 885
 		if ( self::check_selected( $values, $current ) ) {
886
-            echo ' checked="checked"';
886
+			echo ' checked="checked"';
887 887
 		}
888
-    }
888
+	}
889 889
 
890 890
 	public static function check_selected( $values, $current ) {
891 891
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -923,24 +923,24 @@  discard block
 block discarded – undo
923 923
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
924 924
 	}
925 925
 
926
-    /**
927
-     * Flatten a multi-dimensional array
928
-     */
926
+	/**
927
+	 * Flatten a multi-dimensional array
928
+	 */
929 929
 	public static function array_flatten( $array, $keys = 'keep' ) {
930
-        $return = array();
931
-        foreach ( $array as $key => $value ) {
930
+		$return = array();
931
+		foreach ( $array as $key => $value ) {
932 932
 			if ( is_array( $value ) ) {
933 933
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
934
-            } else {
934
+			} else {
935 935
 				if ( $keys == 'keep' ) {
936 936
 					$return[ $key ] = $value;
937 937
 				} else {
938 938
 					$return[] = $value;
939 939
 				}
940
-            }
941
-        }
942
-        return $return;
943
-    }
940
+			}
941
+		}
942
+		return $return;
943
+	}
944 944
 
945 945
 	public static function esc_textarea( $text, $is_rich_text = false ) {
946 946
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -951,11 +951,11 @@  discard block
 block discarded – undo
951 951
 		return apply_filters( 'esc_textarea', $safe_text, $text );
952 952
 	}
953 953
 
954
-    /**
955
-     * Add auto paragraphs to text areas
954
+	/**
955
+	 * Add auto paragraphs to text areas
956 956
 	 *
957
-     * @since 2.0
958
-     */
957
+	 * @since 2.0
958
+	 */
959 959
 	public static function use_wpautop( $content ) {
960 960
 		if ( apply_filters( 'frm_use_wpautop', true ) ) {
961 961
 			$content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -964,26 +964,26 @@  discard block
 block discarded – undo
964 964
 	}
965 965
 
966 966
 	public static function replace_quotes( $val ) {
967
-        //Replace double quotes
967
+		//Replace double quotes
968 968
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
969
-        //Replace single quotes
970
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
971
-        return $val;
972
-    }
973
-
974
-    /**
975
-     * @since 2.0
976
-     * @return string The base Google APIS url for the current version of jQuery UI
977
-     */
978
-    public static function jquery_ui_base_url() {
969
+		//Replace single quotes
970
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
971
+		return $val;
972
+	}
973
+
974
+	/**
975
+	 * @since 2.0
976
+	 * @return string The base Google APIS url for the current version of jQuery UI
977
+	 */
978
+	public static function jquery_ui_base_url() {
979 979
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
980 980
 		$url = apply_filters( 'frm_jquery_ui_base_url', $url );
981
-        return $url;
982
-    }
981
+		return $url;
982
+	}
983 983
 
984
-    /**
985
-     * @param string $handle
986
-     */
984
+	/**
985
+	 * @param string $handle
986
+	 */
987 987
 	public static function script_version( $handle, $default = 0 ) {
988 988
 		global $wp_scripts;
989 989
 		if ( ! $wp_scripts ) {
@@ -1005,12 +1005,12 @@  discard block
 block discarded – undo
1005 1005
 
1006 1006
 	public static function js_redirect( $url ) {
1007 1007
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
1008
-    }
1008
+	}
1009 1009
 
1010 1010
 	public static function get_user_id_param( $user_id ) {
1011 1011
 		if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
1012
-            return $user_id;
1013
-        }
1012
+			return $user_id;
1013
+		}
1014 1014
 
1015 1015
 		$user_id = sanitize_text_field( $user_id );
1016 1016
 		if ( $user_id == 'current' ) {
@@ -1022,14 +1022,14 @@  discard block
 block discarded – undo
1022 1022
 				$user = get_user_by( 'login', $user_id );
1023 1023
 			}
1024 1024
 
1025
-            if ( $user ) {
1026
-                $user_id = $user->ID;
1027
-            }
1025
+			if ( $user ) {
1026
+				$user_id = $user->ID;
1027
+			}
1028 1028
 			unset( $user );
1029
-        }
1029
+		}
1030 1030
 
1031
-        return $user_id;
1032
-    }
1031
+		return $user_id;
1032
+	}
1033 1033
 
1034 1034
 	public static function get_file_contents( $filename, $atts = array() ) {
1035 1035
 		if ( ! is_file( $filename ) ) {
@@ -1044,28 +1044,28 @@  discard block
 block discarded – undo
1044 1044
 		return $contents;
1045 1045
 	}
1046 1046
 
1047
-    /**
1048
-     * @param string $table_name
1049
-     * @param string $column
1047
+	/**
1048
+	 * @param string $table_name
1049
+	 * @param string $column
1050 1050
 	 * @param int $id
1051 1051
 	 * @param int $num_chars
1052
-     */
1053
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
1054
-        $key = '';
1052
+	 */
1053
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
1054
+		$key = '';
1055 1055
 
1056
-        if ( ! empty( $name ) ) {
1056
+		if ( ! empty( $name ) ) {
1057 1057
 			$key = sanitize_key( $name );
1058
-        }
1058
+		}
1059 1059
 
1060 1060
 		if ( empty( $key ) ) {
1061 1061
 			$max_slug_value = pow( 36, $num_chars );
1062
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
1062
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
1063 1063
 			$key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
1064
-        }
1064
+		}
1065 1065
 
1066 1066
 		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
1067 1067
 			$key = $key . 'a';
1068
-        }
1068
+		}
1069 1069
 
1070 1070
 		$key_check = FrmDb::get_var(
1071 1071
 			$table_name,
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 		);
1078 1078
 
1079 1079
 		if ( $key_check || is_numeric( $key_check ) ) {
1080
-            $suffix = 2;
1080
+			$suffix = 2;
1081 1081
 			do {
1082 1082
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1083 1083
 				$key_check = FrmDb::get_var(
@@ -1091,20 +1091,20 @@  discard block
 block discarded – undo
1091 1091
 				$suffix++;
1092 1092
 			} while ( $key_check || is_numeric( $key_check ) );
1093 1093
 			$key = $alt_post_name;
1094
-        }
1095
-        return $key;
1096
-    }
1094
+		}
1095
+		return $key;
1096
+	}
1097 1097
 
1098
-    /**
1099
-     * Editing a Form or Entry
1098
+	/**
1099
+	 * Editing a Form or Entry
1100 1100
 	 *
1101
-     * @param string $table
1102
-     * @return bool|array
1103
-     */
1104
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1105
-        if ( ! $record ) {
1106
-            return false;
1107
-        }
1101
+	 * @param string $table
1102
+	 * @return bool|array
1103
+	 */
1104
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1105
+		if ( ! $record ) {
1106
+			return false;
1107
+		}
1108 1108
 
1109 1109
 		if ( empty( $post_values ) ) {
1110 1110
 			$post_values = stripslashes_deep( $_POST );
@@ -1127,14 +1127,14 @@  discard block
 block discarded – undo
1127 1127
 
1128 1128
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1129 1129
 
1130
-        if ( $table == 'entries' ) {
1131
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1132
-        } else if ( $table == 'forms' ) {
1133
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1134
-        }
1130
+		if ( $table == 'entries' ) {
1131
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1132
+		} else if ( $table == 'forms' ) {
1133
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1134
+		}
1135 1135
 
1136
-        return $values;
1137
-    }
1136
+		return $values;
1137
+	}
1138 1138
 
1139 1139
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1140 1140
 		if ( ! empty( $fields ) ) {
@@ -1147,15 +1147,15 @@  discard block
 block discarded – undo
1147 1147
 	}
1148 1148
 
1149 1149
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1150
-        $post_values = $args['post_values'];
1150
+		$post_values = $args['post_values'];
1151 1151
 
1152
-        if ( $args['default'] ) {
1153
-            $meta_value = $field->default_value;
1154
-        } else {
1152
+		if ( $args['default'] ) {
1153
+			$meta_value = $field->default_value;
1154
+		} else {
1155 1155
 			if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1156 1156
 				if ( ! isset( $field->field_options['custom_field'] ) ) {
1157
-                    $field->field_options['custom_field'] = '';
1158
-                }
1157
+					$field->field_options['custom_field'] = '';
1158
+				}
1159 1159
 				$meta_value = FrmProEntryMetaHelper::get_post_value(
1160 1160
 					$record->post_id,
1161 1161
 					$field->field_options['post_field'],
@@ -1167,31 +1167,31 @@  discard block
 block discarded – undo
1167 1167
 						'field' => $field,
1168 1168
 					)
1169 1169
 				);
1170
-            } else {
1170
+			} else {
1171 1171
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1172
-            }
1173
-        }
1172
+			}
1173
+		}
1174 1174
 
1175 1175
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1176
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1176
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1177 1177
 
1178 1178
 		$field_array = self::start_field_array( $field );
1179 1179
 		$field_array['value'] = $new_value;
1180 1180
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1181 1181
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1182 1182
 
1183
-        $args['field_type'] = $field_type;
1183
+		$args['field_type'] = $field_type;
1184 1184
 
1185 1185
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1186 1186
 
1187 1187
 		if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1188
-            $field_array['unique_msg'] = '';
1189
-        }
1188
+			$field_array['unique_msg'] = '';
1189
+		}
1190 1190
 
1191
-        $field_array = array_merge( $field->field_options, $field_array );
1191
+		$field_array = array_merge( $field->field_options, $field_array );
1192 1192
 
1193
-        $values['fields'][ $field->id ] = $field_array;
1194
-    }
1193
+		$values['fields'][ $field->id ] = $field_array;
1194
+	}
1195 1195
 
1196 1196
 	/**
1197 1197
 	 * @since 3.0
@@ -1212,20 +1212,20 @@  discard block
 block discarded – undo
1212 1212
 		);
1213 1213
 	}
1214 1214
 
1215
-    /**
1216
-     * @param string $table
1217
-     */
1215
+	/**
1216
+	 * @param string $table
1217
+	 */
1218 1218
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1219
-        if ( $table == 'entries' ) {
1220
-            $form = $record->form_id;
1219
+		if ( $table == 'entries' ) {
1220
+			$form = $record->form_id;
1221 1221
 			FrmForm::maybe_get_form( $form );
1222
-        } else {
1223
-            $form = $record;
1224
-        }
1222
+		} else {
1223
+			$form = $record;
1224
+		}
1225 1225
 
1226
-        if ( ! $form ) {
1227
-            return;
1228
-        }
1226
+		if ( ! $form ) {
1227
+			return;
1228
+		}
1229 1229
 
1230 1230
 		$values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1231 1231
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
@@ -1234,26 +1234,26 @@  discard block
 block discarded – undo
1234 1234
 			return;
1235 1235
 		}
1236 1236
 
1237
-        foreach ( $form->options as $opt => $value ) {
1238
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1239
-        }
1237
+		foreach ( $form->options as $opt => $value ) {
1238
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1239
+		}
1240 1240
 
1241 1241
 		self::fill_form_defaults( $post_values, $values );
1242
-    }
1242
+	}
1243 1243
 
1244
-    /**
1245
-     * Set to POST value or default
1246
-     */
1244
+	/**
1245
+	 * Set to POST value or default
1246
+	 */
1247 1247
 	private static function fill_form_defaults( $post_values, array &$values ) {
1248
-        $form_defaults = FrmFormsHelper::get_default_opts();
1248
+		$form_defaults = FrmFormsHelper::get_default_opts();
1249 1249
 
1250
-        foreach ( $form_defaults as $opt => $default ) {
1251
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1250
+		foreach ( $form_defaults as $opt => $default ) {
1251
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1252 1252
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1253
-            }
1253
+			}
1254 1254
 
1255 1255
 			unset( $opt, $default );
1256
-        }
1256
+		}
1257 1257
 
1258 1258
 		if ( ! isset( $values['custom_style'] ) ) {
1259 1259
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1262,10 +1262,10 @@  discard block
 block discarded – undo
1262 1262
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1263 1263
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1264 1264
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1265
-            }
1265
+			}
1266 1266
 			unset( $h );
1267
-        }
1268
-    }
1267
+		}
1268
+	}
1269 1269
 
1270 1270
 	/**
1271 1271
 	 * @since 2.2.10
@@ -1288,33 +1288,33 @@  discard block
 block discarded – undo
1288 1288
 		if ( $possible_email_field ) {
1289 1289
 			$class .= 'show_frm_not_email_to';
1290 1290
 		}
1291
-    ?>
1291
+	?>
1292 1292
 <li>
1293 1293
 	<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>
1294 1294
 	<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>
1295 1295
 	<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>
1296 1296
 </li>
1297 1297
     <?php
1298
-    }
1298
+	}
1299 1299
 
1300 1300
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1301
-        if ( is_array( $str ) ) {
1302
-            return '';
1301
+		if ( is_array( $str ) ) {
1302
+			return '';
1303 1303
 		}
1304 1304
 
1305
-        $length = (int) $length;
1305
+		$length = (int) $length;
1306 1306
 		$str = wp_strip_all_tags( $str );
1307 1307
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1308 1308
 
1309 1309
 		if ( $length == 0 ) {
1310
-            return '';
1311
-        } else if ( $length <= 10 ) {
1310
+			return '';
1311
+		} else if ( $length <= 10 ) {
1312 1312
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1313 1313
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1314
-        }
1314
+		}
1315 1315
 
1316
-        $sub = '';
1317
-        $len = 0;
1316
+		$sub = '';
1317
+		$len = 0;
1318 1318
 
1319 1319
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1320 1320
 
@@ -1322,21 +1322,21 @@  discard block
 block discarded – undo
1322 1322
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1323 1323
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1324 1324
 			if ( $total_len > $length && substr_count( $sub, ' ' ) ) {
1325
-                break;
1326
-            }
1325
+				break;
1326
+			}
1327 1327
 
1328
-            $sub .= $part;
1328
+			$sub .= $part;
1329 1329
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1330 1330
 
1331 1331
 			if ( substr_count( $sub, ' ' ) > $minword && $total_len >= $length ) {
1332
-                break;
1333
-            }
1332
+				break;
1333
+			}
1334 1334
 
1335 1335
 			unset( $total_len, $word );
1336
-        }
1336
+		}
1337 1337
 
1338 1338
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1339
-    }
1339
+	}
1340 1340
 
1341 1341
 	public static function mb_function( $function_names, $args ) {
1342 1342
 		$mb_function_name = $function_names[0];
@@ -1349,17 +1349,17 @@  discard block
 block discarded – undo
1349 1349
 
1350 1350
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1351 1351
 		if ( empty( $date ) ) {
1352
-            return $date;
1353
-        }
1352
+			return $date;
1353
+		}
1354 1354
 
1355 1355
 		if ( empty( $date_format ) ) {
1356 1356
 			$date_format = get_option( 'date_format' );
1357 1357
 		}
1358 1358
 
1359 1359
 		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1360
-            $frmpro_settings = new FrmProSettings();
1360
+			$frmpro_settings = new FrmProSettings();
1361 1361
 			$date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1362
-        }
1362
+		}
1363 1363
 
1364 1364
 		$formatted = self::get_localized_date( $date_format, $date );
1365 1365
 
@@ -1368,8 +1368,8 @@  discard block
 block discarded – undo
1368 1368
 			$formatted .= self::add_time_to_date( $time_format, $date );
1369 1369
 		}
1370 1370
 
1371
-        return $formatted;
1372
-    }
1371
+		return $formatted;
1372
+	}
1373 1373
 
1374 1374
 	private static function add_time_to_date( $time_format, $date ) {
1375 1375
 		if ( empty( $time_format ) ) {
@@ -1451,32 +1451,32 @@  discard block
 block discarded – undo
1451 1451
 		);
1452 1452
 	}
1453 1453
 
1454
-    // Pagination Methods
1454
+	// Pagination Methods
1455 1455
 
1456
-    /**
1457
-     * @param integer $current_p
1458
-     */
1456
+	/**
1457
+	 * @param integer $current_p
1458
+	 */
1459 1459
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1460 1460
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1461 1461
 	}
1462 1462
 
1463
-    /**
1464
-     * @param integer $current_p
1465
-     */
1466
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1467
-        if ( $current_p == 1 ) {
1468
-            return 1;
1469
-        } else {
1470
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1471
-        }
1472
-    }
1463
+	/**
1464
+	 * @param integer $current_p
1465
+	 */
1466
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1467
+		if ( $current_p == 1 ) {
1468
+			return 1;
1469
+		} else {
1470
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1471
+		}
1472
+	}
1473 1473
 
1474 1474
 	/**
1475 1475
 	 * @return array
1476 1476
 	 */
1477 1477
 	public static function json_to_array( $json_vars ) {
1478
-        $vars = array();
1479
-        foreach ( $json_vars as $jv ) {
1478
+		$vars = array();
1479
+		foreach ( $json_vars as $jv ) {
1480 1480
 			$jv_name = explode( '[', $jv['name'] );
1481 1481
 			$last = count( $jv_name ) - 1;
1482 1482
 			foreach ( $jv_name as $p => $n ) {
@@ -1493,77 +1493,77 @@  discard block
 block discarded – undo
1493 1493
 					$l3 = $name;
1494 1494
 				}
1495 1495
 
1496
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1496
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1497 1497
 
1498
-                switch ( $p ) {
1499
-                    case 0:
1500
-                        $l1 = $name;
1501
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1498
+				switch ( $p ) {
1499
+					case 0:
1500
+						$l1 = $name;
1501
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1502 1502
 						break;
1503 1503
 
1504
-                    case 1:
1505
-                        $l2 = $name;
1506
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1504
+					case 1:
1505
+						$l2 = $name;
1506
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1507 1507
 						break;
1508 1508
 
1509
-                    case 2:
1510
-                        $l3 = $name;
1511
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1509
+					case 2:
1510
+						$l3 = $name;
1511
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1512 1512
 						break;
1513 1513
 
1514
-                    case 3:
1515
-                        $l4 = $name;
1516
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1517
-                }
1514
+					case 3:
1515
+						$l4 = $name;
1516
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1517
+				}
1518 1518
 
1519 1519
 				unset( $this_val, $n );
1520
-            }
1520
+			}
1521 1521
 
1522 1522
 			unset( $last, $jv );
1523
-        }
1524
-
1525
-        return $vars;
1526
-    }
1527
-
1528
-    /**
1529
-     * @param string $name
1530
-     * @param string $l1
1531
-     */
1532
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1533
-        if ( $name == '' ) {
1534
-            $vars[] = $val;
1535
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1536
-            $vars[ $l1 ] = $val;
1537
-        }
1538
-    }
1523
+		}
1524
+
1525
+		return $vars;
1526
+	}
1527
+
1528
+	/**
1529
+	 * @param string $name
1530
+	 * @param string $l1
1531
+	 */
1532
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1533
+		if ( $name == '' ) {
1534
+			$vars[] = $val;
1535
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1536
+			$vars[ $l1 ] = $val;
1537
+		}
1538
+	}
1539 1539
 
1540 1540
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1541
-        $tooltips = array(
1542
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1543
-            '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' ),
1544
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1545
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1546
-            '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' ),
1547
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1548
-            '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() ) ),
1549
-        );
1550
-
1551
-        if ( ! isset( $tooltips[ $name ] ) ) {
1552
-            return;
1553
-        }
1554
-
1555
-        if ( 'open' == $class ) {
1556
-            echo ' frm_help"';
1557
-        } else {
1558
-            echo ' class="frm_help"';
1559
-        }
1541
+		$tooltips = array(
1542
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1543
+			'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' ),
1544
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1545
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1546
+			'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' ),
1547
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1548
+			'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() ) ),
1549
+		);
1550
+
1551
+		if ( ! isset( $tooltips[ $name ] ) ) {
1552
+			return;
1553
+		}
1554
+
1555
+		if ( 'open' == $class ) {
1556
+			echo ' frm_help"';
1557
+		} else {
1558
+			echo ' class="frm_help"';
1559
+		}
1560 1560
 
1561 1561
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1562 1562
 
1563
-        if ( 'open' != $class ) {
1564
-            echo '"';
1565
-        }
1566
-    }
1563
+		if ( 'open' != $class ) {
1564
+			echo '"';
1565
+		}
1566
+	}
1567 1567
 
1568 1568
 	/**
1569 1569
 	 * Add the current_page class to that page in the form nav
@@ -1579,35 +1579,35 @@  discard block
 block discarded – undo
1579 1579
 		}
1580 1580
 	}
1581 1581
 
1582
-    /**
1583
-     * Prepare and json_encode post content
1584
-     *
1585
-     * @since 2.0
1586
-     *
1587
-     * @param array $post_content
1588
-     * @return string $post_content ( json encoded array )
1589
-     */
1590
-    public static function prepare_and_encode( $post_content ) {
1591
-        //Loop through array to strip slashes and add only the needed ones
1582
+	/**
1583
+	 * Prepare and json_encode post content
1584
+	 *
1585
+	 * @since 2.0
1586
+	 *
1587
+	 * @param array $post_content
1588
+	 * @return string $post_content ( json encoded array )
1589
+	 */
1590
+	public static function prepare_and_encode( $post_content ) {
1591
+		//Loop through array to strip slashes and add only the needed ones
1592 1592
 		foreach ( $post_content as $key => $val ) {
1593 1593
 			// Replace problematic characters (like &quot;)
1594 1594
 			$val = str_replace( '&quot;', '"', $val );
1595 1595
 
1596 1596
 			self::prepare_action_slashes( $val, $key, $post_content );
1597
-            unset( $key, $val );
1598
-        }
1597
+			unset( $key, $val );
1598
+		}
1599 1599
 
1600
-        // json_encode the array
1601
-        $post_content = json_encode( $post_content );
1600
+		// json_encode the array
1601
+		$post_content = json_encode( $post_content );
1602 1602
 
1603
-	    // add extra slashes for \r\n since WP strips them
1603
+		// add extra slashes for \r\n since WP strips them
1604 1604
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1605 1605
 
1606
-        // allow for &quot
1607
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1606
+		// allow for &quot
1607
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1608 1608
 
1609
-        return $post_content;
1610
-    }
1609
+		return $post_content;
1610
+	}
1611 1611
 
1612 1612
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1613 1613
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1630,55 +1630,55 @@  discard block
 block discarded – undo
1630 1630
 
1631 1631
 	public static function maybe_json_decode( $string ) {
1632 1632
 		if ( is_array( $string ) ) {
1633
-            return $string;
1634
-        }
1633
+			return $string;
1634
+		}
1635 1635
 
1636 1636
 		$new_string = json_decode( $string, true );
1637 1637
 		if ( function_exists( 'json_last_error' ) ) {
1638 1638
 			// php 5.3+
1639
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1640
-                $string = $new_string;
1641
-            }
1639
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1640
+				$string = $new_string;
1641
+			}
1642 1642
 		} elseif ( isset( $new_string ) ) {
1643 1643
 			// php < 5.3 fallback
1644
-            $string = $new_string;
1645
-        }
1646
-        return $string;
1647
-    }
1648
-
1649
-    /**
1650
-     * @since 1.07.10
1651
-     *
1652
-     * @param string $post_type The name of the post type that may need to be highlighted
1653
-     * echo The javascript to open and highlight the Formidable menu
1654
-     */
1644
+			$string = $new_string;
1645
+		}
1646
+		return $string;
1647
+	}
1648
+
1649
+	/**
1650
+	 * @since 1.07.10
1651
+	 *
1652
+	 * @param string $post_type The name of the post type that may need to be highlighted
1653
+	 * echo The javascript to open and highlight the Formidable menu
1654
+	 */
1655 1655
 	public static function maybe_highlight_menu( $post_type ) {
1656
-        global $post;
1656
+		global $post;
1657 1657
 
1658 1658
 		if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1659
-            return;
1660
-        }
1659
+			return;
1660
+		}
1661 1661
 
1662 1662
 		if ( is_object( $post ) && $post->post_type != $post_type ) {
1663
-            return;
1664
-        }
1663
+			return;
1664
+		}
1665 1665
 
1666
-        self::load_admin_wide_js();
1667
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1668
-    }
1666
+		self::load_admin_wide_js();
1667
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1668
+	}
1669 1669
 
1670
-    /**
1671
-     * Load the JS file on non-Formidable pages in the admin area
1670
+	/**
1671
+	 * Load the JS file on non-Formidable pages in the admin area
1672 1672
 	 *
1673
-     * @since 2.0
1674
-     */
1673
+	 * @since 2.0
1674
+	 */
1675 1675
 	public static function load_admin_wide_js( $load = true ) {
1676 1676
 		$version = self::plugin_version();
1677 1677
 		wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1678 1678
 
1679 1679
 		$global_strings = array(
1680 1680
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1681
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1681
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1682 1682
 			'url'          => self::plugin_url(),
1683 1683
 			'loading'      => __( 'Loading&hellip;', 'formidable' ),
1684 1684
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
@@ -1688,7 +1688,7 @@  discard block
 block discarded – undo
1688 1688
 		if ( $load ) {
1689 1689
 			wp_enqueue_script( 'formidable_admin_global' );
1690 1690
 		}
1691
-    }
1691
+	}
1692 1692
 
1693 1693
 	/**
1694 1694
 	 * @since 2.0.9
@@ -1697,9 +1697,9 @@  discard block
 block discarded – undo
1697 1697
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1698 1698
 	}
1699 1699
 
1700
-    /**
1701
-     * @param string $location
1702
-     */
1700
+	/**
1701
+	 * @param string $location
1702
+	 */
1703 1703
 	public static function localize_script( $location ) {
1704 1704
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1705 1705
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1765,28 +1765,28 @@  discard block
 block discarded – undo
1765 1765
 		}
1766 1766
 	}
1767 1767
 
1768
-    /**
1768
+	/**
1769 1769
 	 * Echo the message on the plugins listing page
1770 1770
 	 *
1771
-     * @since 1.07.10
1772
-     *
1773
-     * @param float $min_version The version the add-on requires
1774
-     */
1771
+	 * @since 1.07.10
1772
+	 *
1773
+	 * @param float $min_version The version the add-on requires
1774
+	 */
1775 1775
 	public static function min_version_notice( $min_version ) {
1776
-        $frm_version = self::plugin_version();
1776
+		$frm_version = self::plugin_version();
1777 1777
 
1778
-        // check if Formidable meets minimum requirements
1778
+		// check if Formidable meets minimum requirements
1779 1779
 		if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1780
-            return;
1781
-        }
1780
+			return;
1781
+		}
1782 1782
 
1783 1783
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1784 1784
 		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">' .
1785
-        esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1786
-        '</div></td></tr>';
1787
-    }
1785
+		esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1786
+		'</div></td></tr>';
1787
+	}
1788 1788
 
1789
-    public static function locales( $type = 'date' ) {
1789
+	public static function locales( $type = 'date' ) {
1790 1790
 		$locales = array(
1791 1791
 			'en' => __( 'English', 'formidable' ),
1792 1792
 			''   => __( 'English/Western', 'formidable' ),
@@ -1865,8 +1865,8 @@  discard block
 block discarded – undo
1865 1865
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1866 1866
 		$locales = apply_filters( 'frm_locales', $locales );
1867 1867
 
1868
-        return $locales;
1869
-    }
1868
+		return $locales;
1869
+	}
1870 1870
 
1871 1871
 	/**
1872 1872
 	 * Used to filter shortcode in text widgets
Please login to merge, or discard this patch.